思路

开map记录字符串之间的映射关系就可以了。

代码

//#pragma GCC optimize("Ofast", "inline", "-ffast-math")
//#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define int long long
using namespace std;
const int N=2e5+7;
const int mod=1e9+7;

//int read(){	int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-') f=f*-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}

map<string,string>mp;
map<string,int>vis;
string str1,str2; 

signed main(){
	for(int i=1;i<=3;i++){
		cin>>str1>>str2;
		mp[str2]=str1;
		vis[str1]=vis[str2]=1; 
	}
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>str1;
		if(!vis[mp[str1]]) cout<<"Fake\n";
		else cout<<mp[str1]<<"\n";
	} 
	return 0;
}