#include<iostream>
using namespace std;
struct p{
	string a,b;
}s[105];
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++) cin>>s[i].a>>s[i].b;
	while(q--){
		string x,y;
		cin>>x>>y;
		cout<<0<<endl;
	}	
//	cout<<"Why is it so hard?";
	return 0;
}
/*
The sky is getting darker, there is only tapping keyboard sounds. 
There is water on my face, I don't know if it is sweat or tears. 
Oh, it looks like I'm going to dye here. 
I think I can only get 25+16+0+0.
It's my first CSP-S, why is it so hard?! (2025.11.1 18:07)

Please give me some pts, please.
*/
