#include <iostream>
#include <cstring>
#include <stack>
#include <cstdio>
using namespace std;
 
int n;
char str[10];
 
stack<int> num;
stack<char> sign;
 
int res;
 
int main()
{
    cin >> n;
    getchar();
    for (int i = 0; i < n; i++)
    {
        res = 0;
        cin >> str;
        while (!num.empty()) num.pop();
        while (!sign.empty()) sign.pop();
        int  j = 0;
        while (j < strlen(str))
        {
            if (str[j] >= '0' && str[j] <='9')
            {
                num.push(str[j] - '0');
            }
            else
                if (str[j] == '+')
                {
                    sign.push(str[j]);
                }
                else
                    if (str[j] == '-')
                    {
                        sign.push('+');
                        num.push((str[j + 1] - '0') * (-1));
                        j++;
                    }
                    else
                        if (str[j] == 'x')
                        {
                            int former = num.top();
                            num.pop();
                            num.push((str[j + 1] - '0') * former);
                            j++;
                        }
                        else
                            if (str[j] == '/')
                            {
                                int former = num.top();
                                num.pop();
                                num.push(former /( str[j + 1] - '0'));
                                j++;
                            }
            j++;
        }
        while (!num.empty())
        {
            res += num.top();
            num.pop();
        }
        if (res == 24            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}