#include <bits/stdc++.h>
using namespace std;
int main()
{
int T, n, ans = 0;
cin >> T;
while (T--) {
string s, t;
ans = 0;
cin >> n >> s >> t;
if (s == t) {
cout << 0 << endl;
continue;
}
cout << 1 << endl;
}
return 0;
}