#include<iostream>
#include<algorithm>
#include<cstring>
#define ll long long
#define x first
#define y second
using namespace std;
int n,m;
int main(){
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	cin>>n>>m;
	for(int i=0;i<n;i++){
		string a,b;
		cin>>a>>b;
	}
	for(int i=0;i<m;i++){
		string a,b;
		cin>>a>>b;
	}
	for(int i=0;i<m;i++)cout<<0<<endl;
	
	return 0;
}
