#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<iomanip>
using namespace std;
long long A[100100];
int main(){
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout); 
	int n,q,i,v=0;
	string s,s1,t,t1;
	cin>>n>>q;
	for(i=0;i<n;i++){
		cin>>s>>s1;
	}
	for(i=0;i<q;i++){
		cin>>t>>t1;
	}
	for(i=0;i<q;i++){
		cout<<0<<endl;
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
