#include<bits/stdc++.h>
using namespace std;
int n,q;
int main(){
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	cin>>n>>q;
	while(n--){
		string s,t;cin>>s>>t;
	}while(q--){
		string s,t;cin>>s>>t;
		cout<<"0\n";
	}
	return 0;
}


