/* Author: Peter Schaeffer */
#include <stdio.h>
#include <string.h>

int i, j, p, g, P[50];
FILE *in;
char name[50][24];

int main()
{
	in=stdin;//fopen("ballot.in", "r");
	fscanf(in, " %d %d", &p, &g);
	for(i=0; i<p; i++)
	{
		int dummy;
		fscanf(in, " %s %d.%d", name[i], &dummy, &P[i]);
		P[i]+=dummy*10;
	}
	for(i=1; i<=g; i++)
	{
		int ok=0;
		int res=0;
		while(1)
		{
			char pt[24], op[4];
			int dummy;
			fscanf(in, " %s %s", pt, op);
			for(j=0; j<p; j++)
				if (!strcmp(pt, name[j]))
					res+=P[j];
			if (op[0]=='+') continue;
			fscanf(in, " %d", &dummy);
			dummy*=10;
			if (!strcmp(op, "="))
			{ if (res == dummy) ok=1; }
			if (!strcmp(op, "<"))
			{ if (res < dummy) ok=1; }
			if (!strcmp(op, ">"))
			{ if (res > dummy) ok=1; }
			if (!strcmp(op, "<="))
			{ if (res <= dummy) ok=1; }
			if (!strcmp(op, ">="))
			{ if (res >= dummy) ok=1; }
			break;
		}
		if (ok)
			printf("Guess #%d was correct.\n", i);
		else
			printf("Guess #%d was incorrect.\n", i);
	}
	return 0;
}
