#include<bits/stdc++.h>
using namespace std;
int priority(char c) {
if (c == '#') return 0;
else if (c == '$') return 1;
else if (c == '+' || c == '-') return 2;
else return 3;
}
int calculate(int x, int y, char c) {
if (c == '+') {
return x + y;
} else if (c == '-') {
return x - y;
} else if (c == 'x') {
return x * y;
} else {
return x / y;
}
}
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
string str;
cin >> str;
stack<char>oper;
stack<int>data;
oper.push('#');
str += '$';
for(int j=0;j<str.size();){
if (str[j] <= '9' && str[j] >= '0') {
data.push((int)(str[j] - 48));
j++;
} else {
char c = str[j];
char topc = oper.top();
if (priority(c) <= priority(topc)) {
int y = data.top();
data.pop();
int x = data.top();
data.pop();
int result = calculate(x, y, topc);
data.push(result);
oper.pop();
} else {
oper.push(c);
j++;
}
}
}
if(data.top()==24) printf("Yes\n");
else {
printf("No\n");
}
}
return 0;
}