#include<bits/stdc++.h>
#define deb(a) cout<<#a<<" is: "<<a<<endl;
#define dl() cout<<"--------------\n";
#define at(i) cout<<"at"<<i<<endl;
#define print(arr, n) for(int i=0;i<n;i++) cout<<arr[i]<<" ";
#define nl() cout<<"\n";
#define f first
#define s second
typedef long long ll;
typedef long double ld;
using namespace std;
main(){
int t; cin>>t;
while(t--){
int n; cin>>n;
string a, b; cin>>a>>b;
if(a == b){
cout<<0;
}
else{
cout<<1;
}
nl();
}
}