#include<bits/stdc++.h>
using namespace std;
long long n,m;
string s1,s2;
int main(){
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	cin>>n>>m;
	for(long long i=0;i<n;i++){
		cin>>s1>>s2;
	}for(long long i=0;i<m;i++){
		cin>>s1>>s2;
		cout<<0;
		if(i!=m-1) cout<<endl;
	}
}
 
