package Main;
import java.util.*;
public class Main {
public static void main(String[] args) {
int x = 0;
String str = "";
Scanner sc = new Scanner(System.in);
x = sc.nextInt();
List<String> list = new ArrayList();
for (int i = 0; i < x; i++) {
// 使用 next 接收字符串 如果用 nextLine 会直接接收换行 next会对无效字符串进行过滤
str = sc.next();
// 每完成一次进行一次list集合清0防止影响下次计算
list.clear();
// 读取每个字符以字符串形式放进list集合 因为题目要求是1-9
for (int j = 0; j < str.length(); j++) {
list.add(str.substring(j, j + 1));
}
// 先循环进行 乘除运算 知道没有乘除符号为止
for (int s = 0; s < list.size() ; s++) {
if (list.get(s).equals("x")) {
// 得到 x 符号前边的数字 和后边的数字 进行运算 结果替换前边数字
int num1 = Integer.parseInt(list.get(s - 1));
int num2 = Integer.parseInt(list.get(s + 1));
list.set(s - 1, String.valueOf(num1 * num2));
// 对运算符和后边数字进行清除
// 先清除后边的在清楚前边的 或者直接写 2次 remove(s)
list.remove(s + 1);
list.remove(s);
// 最后对s的位置归到上一个数字 因为你改动了集合 不然可能会漏掉
s = s-1;
} else if (list.get(s).equals("/")) {
int num1 = Integer.parseInt(list.get(s - 1));
int num2 = Integer.parseInt(list.get(s + 1));
list.set(s - 1, String.valueOf(num1 / num2));
list.remove(s + 1);
list.remove(s);
s = s-1;
}
}
for (int s = 0; s < list.size() ; s++) {
if (list.get(s).equals("+")) {
int num1 = Integer.parseInt(list.get(s - 1));
int num2 = Integer.parseInt(list.get(s + 1));
list.set(s - 1, String.valueOf(num1 + num2));
list.remove(s + 1);
list.remove(s);
s = s-1;
} else if (list.get(s).equals("-")) {
int num1 = Integer.parseInt(list.get(s - 1));
int num2 = Integer.parseInt(list.get(s + 1));
list.set(s - 1, String.valueOf(num1 - num2));
list.remove(s + 1);
list.remove(s);
s = -1;
}
}
// 此时list集合只剩下一个数据 判断是不是24即可
// 注意 输出流 和输入流不影响 判题机制只判断输出流所以一边输入一边输出不影响
if (Integer.parseInt(list.get(0)) == 24) {
System.out.println("Yes");
} else {
System.out.println("No");
}
}
}
}