#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<ctime>
#include<cstdio>
#include<queue>
#include<list>
#include<set>
#include<map>
#include<vector>
#include<stack>
using namespace std;
int main()
{
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	int n,q;
	cin>>n>>q;
	for(int i=1;i<=n;i++){
		string s1,s2;
		cin>>s1>>s2;
	}
	for(int i=1;i<=q;i++){
		string t1,t2;
		cin>>t1>>t2;
	}
	for(int i=1;i<=q;i++){
		cout<<0<<endl;
	}
	return 0;
}

