#include typedef long long ll; using namespace std; const ll MOD = 1e9+7; const ll MAX= 1000001; ll fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i%MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } //二項計数計算 ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0)return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll permutation(ll n,ll k){ if (n < k) return 0; if (n < 0 || k < 0)return 0; return fac[n] * (finv[n-k]%MOD) % MOD; } ll H(ll n, ll k){ if(n==0&&k==0)return 1; return COM(n+k-1,k); } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; char a,b,c,d; int x,y; cin>>n; COMinit(); while(cin>>n){ cin>>a>>b>>x>>c>>y>>d; if(a=='C'){ cout<