#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;
int i=0;
while(a[i]!=b[i]&&i<n)
i++;
cout<<(i?"1\n":"0\n");
}
};