#include<bits/stdc++.h>
using namespace std;
struct abc{
	string a,b;
	int c;
}p[200005];
int main()
{
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	int n,t;
	cin>>n>>t;
	for(int i=1;i<=n;i++)
	{
		cin>>p[i].a>>p[i].b;
	}
	while(t--)
	{
		string x,y;
		cin>>x>>y;
		cout<<0<<endl;
	}
	return 0;
}
