#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ll long long
const int N =26;
int occ[N];
int main() {
IOS
int t;cin>>t;
while(t--){;
int n;cin>>n;
string a,b;cin>>a>>b;
cout<<(a!=b?"1\n":"0\n");
}
};