#include <stdio.h>
#include <string.h>
char *num[11] = {"zero","one","two","three","four","five","six","seven","eight","nine","ten"};
char* compareChar(char* s1, char* s2){
	int i=0, j;
	while(s1[i]){
		j=0;
		while(s2[j]){
			if(s1[i]==s2[j]){
				//printf(">%c %d %s\n", s1[i], j, s2);
				s2[j] = '-';
				break;
			}
			j++;
		}
		//printf(">>%s\n", s2);
		if(!s2[j]) return "No";
		i++;
	}
	//printf(">>>%s\n", s2);
	if(s2[i]) return "No";
	return "Yes";
}
int getN(char* s){
	int i;
	for(i=0; i<11; i++){
		if(strcmp(s,num[i])==0){
			//printf(">>>%s = %d\n", s, i);
			return i;
		}
	}
	return -1;
}
int main() {
	int n, i, j, r, t;
	char a[11], b[11], c[11], op[2],e[2];

	scanf("%d",&n);
	while(n--){
		scanf("%s%s%s%s%s", a,op,b,e,c);
		r = getN(a);
		t=getN(b);
		if(op[0]=='+') r+=t;
		else if(op[0]=='-') r-=t;
		else if(op[0]=='*') r*=t;
		else r/=t;
		if(r<0 || r>11) printf("No\n");
		else printf("%s\n", compareChar(num[r], c));
	}
	return 0;
}
// int getN(char* s){
// 	if(!strcmp(s,"zero")) return 0;
// 	if(!strcmp(s,"one")) return 1;
// 	if(!strcmp(s,"two")) return 2;
// 	if(!strcmp(s,"three")) return 3;
// 	if(!strcmp(s,"four")) return 4;
// 	if(!strcmp(s,"five")) return 5;
// 	if(!strcmp(s,"six")) return 6;
// 	if(!strcmp(s,"seven")) return 7;
// 	if(!strcmp(s,"eight")) return 8;
// 	if(!strcmp(s,"nine")) return 9;
// 	if(!strcmp(s,"ten")) return 10;
// 	return -1;
// }
// char* getS(int n){
// 	if(n==0) return "zero";
// 	if(n==1) return "one";
// 	if(n==2) return "two";
// 	if(n==3) return "three";
// 	if(n==4) return "four";
// 	if(n==5) return "five";
// 	if(n==6) return "six";
// 	if(n==7) return "seven";
// 	if(n==8) return "eight";
// 	if(n==9) return "nine";
// 	if(n==10) return "ten";
// 	return "!";
// }
// int main() {
// 	int n, i, j, r, t;
// 	char a[11], b[11], c[11], op[2],e[2];
// 	scanf("%d",&n);
// 	while(n--){
// 		scanf("%s%s%s%s%s", a,op,b,e,c);
// 		r = getN(a);
// 		t=getN(b);
// 		if(op[0]=='+') r+=t;
// 		else if(op[0]=='-') r-=t;
// 		else if(op[0]=='*') r*=t;
// 		else r/=t;
// 		printf("%s\n", compareChar(getS(r), c));
// 	}
// 	return 0;
// }
