#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
void solve() {
string s;
string t;
int n;
cin >> n;
cin >> s >> t;
if (s == t) {
cout << 0 << endl;
} else {
cout << 1 << endl;
}
}
int main() {
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}