#include<bits/stdc++.h>
using namespace std;
const int NN=2e5+5;
int n,q;
string s1,s2;
int main()
{
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)
	{
		cin>>s1>>s2;
	}
	for(int i=1;i<=q;i++)
	{
		cin>>s1>>s2;
		printf("0\n");
	}
	return 0;
}

