#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,q;
string s1,s2;
string t1,t2;
signed main(){
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	cin>>n>>q;
	for(int i=1;i<=n;i++)cin>>s1>>s2;
	while(q--){
		cin>>t1>>t2;
		cout<<0<<"\n";
	}
	return 0;
}

