#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=100005;
ll ans;
int main(){
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	ll n,q;
	cin>>n>>q;
	for(int i=1;i<=n;i++){
		string a1,b1;
		cin>>a1>>b1;
	}
	for(int i=1;i<=q;i++){
		ll s1;
		cin>>s1;
		cout<<0<<endl;
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
} 
