#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void magic() {
int n; cin>>n;
string s, t; cin>>s>>t;
if(s == t) cout<<0<<endl;
else cout<<1<<endl;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("intput.in", "r", stdin); // INPUT
// freopen("road.out", "w", stdout); // OUTPUT JUST IN CASE
int tt = 1; cin>>tt;
while (tt--)
magic();
}