#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	int n,q;
	cin>>n>>q;
	for(int i=1;i<=n;i++){
		string s;
		cin>>s;
		cin>>s;
	}
	for(int i=1;i<=q;i++){
		string s;
		cin>>s;
		cin>>s;
		cout<<"1\n";
	}
	fclose(stdin);
	fclose(stdout);
	return 0; 
}
