#include<cstdio>
#define F(i,l,r) for(int i=l,i##_end=r;i<i##_end;++i)
using namespace std;
const int N=2e5+5;
template<typename T>void read(T &x)
{
	bool neg=false;
	unsigned char c=getchar();
	for(;(c^48)>9;c=getchar())if(c=='-')neg=true;
	for(x=0;(c^48)<10;c=getchar())x=(x<<3)+(x<<1)+(c^48);
	if(neg)x=-x;
}
int n,f[N][8],b=1;
char s[N],x[N];
int main()
{
	read(n);scanf("%s%s",s,x);
	F(i,0,n/2)s[i]^=s[n-1-i]^=s[i]^=s[n-1-i];
	F(i,0,n/2)x[i]^=x[n-1-i]^=x[i]^=x[n-1-i];
	f[0][0]=1;
	F(i,0,n)
	{
		int t=(s[i]-'0')*b%7;
		if(x[i]=='A')F(j,0,7)f[i+1][j]=f[i][j]&&f[i][(j+t)%7];
		else F(j,0,7)f[i+1][j]=f[i][j]||f[i][(j+t)%7];
		b=b*10%7;
	}
	puts(f[n][0]?"Takahashi":"Aoki");
	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const long long mod = 1000000007;
// const long long mod =  998244353;

int main(void){
    int t;
    cin >> t;
    while(t--){
        long long n, a, b;
        cin >> n >> a >> b;
        if(a+b > n){
            cout << 0 << endl;
            continue;
        }
        long long c = n - a - b + 1;
        long long d = c*(c+1)/2 % mod;
        long long ans = d;
        ans *= (n-a+1) * (n-b+1) % mod;
        ans %= mod;
        // cout << ans << endl;
        ans += mod - (d*d%mod);
        cout << ans*4 % mod << endl;

    }
}
