#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e6+9,M=1e4+9,INF=1e18;
ll n,q;
string a,b;
int main() {
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	cin.tie(0)->sync_with_stdio(0);
	cin>>n>>q;
	for(int i=1;i<=n;i++){
		cin>>a>>b;
	}
	for(int i=1;i<=q;i++){
		cin>>a>>b;
		cout<<0<<'\n';
	}
	return 0;
}
