#include "bits/stdc++.h"
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
int t;
cin >> t;
while(t--){
int n;
string a, b;
cin >> n >> a >> b;
if(a == b)
cout << 0;
else
cout << 1;
cout << '\n';
}
}