#include<iostream>
using namespace std;
typedef long long ll;
const ll N=1e3+10;
ll n,m,cnt;
string s[N][3];
int main(){
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>s[i][1]>>s[i][2];
	while(m--){
		string a,b;
		cin>>a>>b;
		cout<<0<<endl;
	}
	return 0;
}

