#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#define ll long long
#define fir first
#define sec second
#define pb push_back
using namespace std;
ll n,q;
string a,b; 
int main(){
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout); 
	cin>>n>>q;
	for(ll i=1;i<=n;i++)cin>>a>>b;
	for(ll i=1;i<=q;i++)cin>>a>>b;
	while(q--){
		cout<<0<<endl;
	}
	return 0;
}

