#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+10,MOD=1e9+7;
int T,x[N],a[N],b[N],pos[N],val[N],n,m,V,ans;
map<int,int>mp;
bool A;
int read(){
	int res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while('0'<=ch&&ch<='9') res=res*10+ch-'0',ch=getchar();
	return res*f;
}
ll qpow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
bool check(){
	bool vis[2]={true,true};
	if(x[1]) vis[(x[1]-1)^1]=false;
	for(int i=2;i<=n;i++){
		bool now[2]={true,true};
		if((!vis[0]&&a[i-1]==1)||(!vis[1]&&a[i-1]==0)) now[b[i-1]^1]=false;
		if(x[i]&&!now[x[i]-1]) return false;
		vis[0]=now[0],vis[1]=now[1];
	}
	return true;
}
void dfs(int u){
	if(u==n){ans+=check();return;}
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			a[u]=i,b[u]=j;
			dfs(u+1);
		}
	}
}
void solveA(){
	ll Furry=0,temp=(V-1)*V%MOD+1;
	Furry=qpow(temp,m-1);
	printf("%lld\n",(ll)((Furry+qpow(V,n-m)*qpow(V,n-m)%MOD)%MOD));
}
void furry(){
	n=read(),m=read(),V=read(),ans=0;
	if(n<=12){
		for(int i=1;i<=n;i++) x[i]=0;
	}
	bool Furry=true;A=true,mp.clear();
	for(int i=1;i<=m;i++){
		pos[i]=read(),val[i]=read();
		if(mp[pos[i]]&&mp[pos[i]]!=val[i]) Furry=false;
		mp[pos[i]]=val[i];
		if(n<=12) x[pos[i]]=val[i];
		if(pos[i]!=i) A=false;
	}
	if(!Furry){printf("0\n");return;}
	if(V==1){printf("1\n");return;}
	if(V<=2&&n<=12) dfs(1),printf("%d\n",ans);
	else if(m==1) printf("%lld\n",(ll)(qpow(V,n-1)*qpow(V,n-1)%MOD));
	else if(A) solveA();
	else printf("Furry!!!\n");
}
int main(){
	freopen("assign.in","r",stdin);
	freopen("assign.out","w",stdout);
	T=read();
	while(T--) furry();
	fclose(stdin);fclose(stdout);
	return 0;
}
