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

