#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define vec(d) vector<d>
#define cin(x) for(auto &i:x)cin>>i;
#define el endl
#define pb push_back
void solve()
{
int n;
cin >>n;
string s,c;
cin>>s>>c;
cout<<(s!=c)<<el;
}
int main()
{
FAST;
int t;
cin>>t;
while(t--)
{
solve();
}
}