#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int inf = 1e9;
const ll infll = 1e18;
const int M = 1000000007;
const int N = 2e5;
void testCase(){
int n;
string s1, s2;
cin >> n >> s1 >> s2;
puts(s1 == s2?"0":"1");
}
int main(){
int T = 1;
scanf("%d", &T);
while(T--){
testCase();
}
}