#include<bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=1;i>=b;i--)
#define ll long long
#define pii pair<int,int>
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
const int N=1e6+5;
const int P=1e9+7;
void solve()
{
	int n,q;
	for(int i=1;i<=n;++i){
		string s1,s2;
		cin>>s1>>s2;
	} 
	for(int i=1;i<=q;++i){
		string t1,t2;
		cin>>t1>>t2;
		cout<<0<<'\n';
	}
}
int main()
{
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	int T=1;
	//cin>>T;
	while(T--)solve();
	return 0;
}

