#include<bits/stdc++.h>
using namespace std;
int main()
{
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	int n,p;
	cin>>n>>p;
	string f;
	for(int i=1;i<=n;i++)
	{
		cin>>f;
	}
	string g,h;
	for(int i=1;i<=p;i++)
	{
		cin>>g>>h;
	}
	for(int i=1;i<=p;i++)
	{
		cout<<0<<endl;
	}
	return 0;
}
