// http://w...content-available-to-author-only...t.com/judge/problem/read/XHAENEUNG
#include <iostream>
#include <list>
using namespace std;
int convert_s_i(string a)
{
if(a.compare("zero") == 0) return 0;
if(a.compare("one") == 0) return 1;
if(a.compare("two") == 0) return 2;
if(a.compare("three") == 0) return 3;
if(a.compare("four") == 0) return 4;
if(a.compare("five") == 0) return 5;
if(a.compare("six") == 0) return 6;
if(a.compare("seven") == 0) return 7;
if(a.compare("eight") == 0) return 8;
if(a.compare("nine") == 0) return 9;
if(a.compare("ten") == 0) return 10;
return -1;
}
string convert_i_s(int num)
{
switch(num)
{
case 0: return "zero" ;
case 1: return "one" ;
case 2: return "two" ;
case 3: return "three" ;
case 4: return "four" ;
case 5: return "five" ;
case 6: return "six" ;
case 7: return "seven" ;
case 8: return "eight" ;
case 9: return "nine" ;
case 10: return "ten" ;
default :
return 0;
}
}
int compute(int a, int b, char operate)
{
if(operate == '+') return a + b;
if(operate == '-') return a - b;
if(operate == '*') return a * b;
if(operate == '/') return a / b;
return -1;
}
int main()
{
int testcase;
cin >> testcase;
for(int counter1 = 0 ; counter1 < testcase ; counter1++)
{
int a, b, real_answer;
string s_a, s_b, s_c, s_compute;
char operate, dummy;
cin >> s_a >> operate >> s_b >> dummy >> s_c;
cout << s_a << " " << operate << " " << s_b << " " << dummy << " " << s_c << endl;
a = convert_s_i(s_a);
b = convert_s_i(s_b);
real_answer = compute(a, b, operate);
s_compute = convert_i_s(real_answer);
int s_compute_size = s_compute.size();
int s_c_size = s_c.size();
list<char> l_compute, l_c;
list<char>::iterator it1 = l_compute.begin();
list<char>::iterator it2 = l_c.begin();
// debug
// cout << " size : " << s_compute_size << " " << s_c_size << endl;
if(s_compute_size != s_c_size)
cout << "No" << endl;
else
{
for(int counter = 0 ; counter < s_compute_size ; counter++)
{
if(s_compute.at(counter) >= 'a' && s_compute.at(counter) <= 'z')
l_compute.push_front(s_compute.at(counter));
}
for(int counter = 0 ; counter < s_c_size ; counter++)
{
if(s_c.at(counter) >= 'a' && s_c.at(counter) <= 'z')
l_c.push_front(s_c.at(counter));
}
l_compute.sort();
l_c.sort();
bool f_success = true;
// avoid dummy char (like \n, null)
it1++;
it2++;
for(int counter = 0 ; counter < s_compute_size ; counter++)
{
// cout << *it1 << " " << *it2 << endl;
if(*it1++ != *it2++)
{
f_success = false;
break;
}
}
if(f_success)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
}
}