#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MOD = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 210;
const ll BSIZ= 800;
int dp[MAXN][MAXN][MAXN][3][2];
int N,T,a,b;
set<int> S[MAXN];
void rdin(int x){
cin>>a;
if(S[x].find(a)!=S[x].end())S[x].erase(a);
else S[x].insert(a);
}
int ask(int ab,int ac,int bc,int turn,int used){
if(min({ab,ac,bc})<0)return 0;
if(dp[ab][ac][bc][turn][used]!=-1)return dp[ab][ac][bc][turn][used];
if(ab==0&&ac==0&&bc==0)return dp[ab][ac][bc][turn][used]=1;
int ans=0;
if(turn==0){
// a is moving to b, can either move one of ab and one of ac
if(ab==0&&ac==0){
ans=ask(ab,ac,bc,1,used);
}else{
ans+=ab*ask(ab-1,ac,bc,1,1);
ans+=ac*ask(ab,ac-1,bc+1,1,used);
}
}else if(turn==1){
if(ab==0&&bc==0){
ans=asn(ab,ac,bc,2,used);
}else{
ans+=bc*ask(ab,ac,bc-1,2,1);
ans+=ab*ask(ab-1,ac+1,bc,2,used);
}
}else{
if(ac==0&&bc==0){
if(used)ans=ask(ab,ac,bc,0,0);
}else{
ans+=ac*ask(ab,ac-1,bc,0,0);
if(used){
ans+=bc*ask(ab+1,ac,bc-1,0,0);
}
}
}
// cerr<<ab<<' '<<ac<<' '<<bc<<' '<<turn<<' '<<used<<' '<<ans<<'\n';
return dp[ab][ac][bc][turn][used]=ans%MOD;
}
int main(){
cin>>N>>T;
memset(dp,-1,sizeof(dp));
while(T--){
for(int i=0;i<3;++i)S[i].clear();
for(int i=0;i<2*N;++i){rdin(0);}
for(int i=0;i<2*N;++i){rdin(1);}
for(int i=0;i<2*N;++i){rdin(2);}
int ab=0;
int ac=0;
int bc=0;
for(auto i:S[0])for(auto j:S[1])if(i==j)++ab;
for(auto i:S[0])for(auto j:S[2])if(i==j)++ac;
for(auto i:S[1])for(auto j:S[2])if(i==j)++bc;
cout<<ask(ab,ac,bc,0,0)<<'\n';
}
}
Compilation message
fishing.cpp: In function 'int ask(int, int, int, int, int)':
fishing.cpp:45:17: error: 'asn' was not declared in this scope
ans=asn(ab,ac,bc,2,used);
^~~
fishing.cpp:45:17: note: suggested alternative: 'ask'
ans=asn(ab,ac,bc,2,used);
^~~
ask