#pragma warning(disable:4996)
#include "stdio.h"
#include "stdlib.h"
#include "string.h"

struct list
{
	struct list* next;
	char name[30];
	int number;
};


int main()
{
	struct list dictionary[26][26][26] = { {NULL,{0},0} };
	struct list *input;
	struct list *pool = (struct list*)calloc(sizeof(struct list) * 100000, sizeof(struct list));
	int pool_used = 0;
	int index_number;
	char name[30] = { 0 };
	scanf("%d", &index_number);
	for (int i = 0; i < index_number; i++)
	{
		scanf("%s", &name);
		input = &dictionary[name[0] - 97][name[1] - 97][name[2] - 97];
		while (input->number != 0)
		{
			if (input->next == 0 && pool_used < 100000)
			{
				input->next = &pool[pool_used++];
			}
			input = input->next;
		}
		scanf("%d", &input->number);
		strncpy(input->name, name, 30);
	}
	while (scanf("%s", &name) != EOF)
	{
		input = &dictionary[name[0] - 97][name[1] - 97][name[2] - 97];
		while (input->next != NULL)
		{
			if (strncmp(name, input->name, 30) == 0)
			{
				break;
			}
			input = input->next;
		}

		if((strncmp(name, input->name, 30) != 0))printf("Not found\n");
		else printf("%s=%d\n", name, input->number);

	}
	free(pool);
	return 0;
}