#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

string ope = "+-*^";
vector<long long> variable(256);

string normalize(string s)
{
    // 連続するスペースを1つのスペースに変換、先頭と末尾のスペースを削除
    int n = s.size();
    string t = s.substr(0, 1);
    for(int i=1; i<n; ++i){
        if(s[i] != ' ' || s[i-1] != ' ')
            t += s[i];
    }
    if(t[0] == ' ')
        t = t.substr(1);
    if(t[t.size()-1] == ' ')
        t = t.substr(0, t.size()-1);
    s = t;

    // 必要に応じて * を挿入する
    n = s.size();
    t = s.substr(0, 1);
    for(int i=1; i<n; ++i){
        if((isalnum(s[i-1]) || s[i-1] == ')') && (isalnum(s[i]) || s[i] == '(') && !(isdigit(s[i-1]) && isdigit(s[i])))
            t += '*';
        t += s[i];
    }
    s = t;

    // スペースを * に変換、もしくは削除する
    n = s.size();
    t = "";
    for(int i=0; i<n; ++i){
        if(s[i] == ' '){
            if(s[i-1] != '(' && s[i+1] != ')' && ope.find(s[i-1]) == string::npos && ope.find(s[i+1]) == string::npos)
                t += '*';
        }else{
            t += s[i];
        }
    }

    return t;
}

map<vector<int>, long long> calculate(string s)
{
    int n = s.size();
    
    bool isNum = true;
    for(int i=0; i<n; ++i){
        if(!isdigit(s[i]))
            isNum = false;
    }
    if(isNum){
        map<vector<int>, long long> ret;
        long long tmp = 0;
        for(int i=0; i<n; ++i){
            tmp *= 10;
            tmp += s[i] - '0';
        }
        if(tmp != 0)
            ret[vector<int>(26, 0)] = tmp;
        return ret;
    }

    if(n == 1){
        map<vector<int>, long long> ret;
        vector<int> tmp(26, 0);
        tmp[s[0]-'a'] = 1;
        ret[tmp] = 1;
        return ret;
    }

    for(int i=0; i<4; ++i){
        int bracket = 0;
        for(int j=n-1; j>=0; --j){
            if(s[j] == '(')
                ++ bracket;
            else if(s[j] == ')')
                -- bracket;
            else if(s[j] == ope[i] && bracket == 0){
                string t1 = s.substr(0, j);
                string t2 = s.substr(j+1);
                map<vector<int>, long long> a = calculate(t1);
                map<vector<int>, long long> b = calculate(t2);

                map<vector<int>, long long> ret;
                if(i == 0){
                    ret = a;
                    for(map<vector<int>, long long>::iterator it=b.begin(); it!=b.end(); ++it)
                        ret[it->first] += it->second;
                }else if(i == 1){
                    ret = a;
                    for(map<vector<int>, long long>::iterator it=b.begin(); it!=b.end(); ++it)
                        ret[it->first] -= it->second;
                }else if(i == 2){
                    for(map<vector<int>, long long>::iterator it1=a.begin(); it1!=a.end(); ++it1){
                        for(map<vector<int>, long long>::iterator it2=b.begin(); it2!=b.end(); ++it2){
                            vector<int> tmp(26);
                            for(int k=0; k<26; ++k)
                                tmp[k] = it1->first[k] + it2->first[k];
                            ret[tmp] += it1->second * it2->second;
                        }
                    }
                }else{
                    vector<int> tmp(26);
                    for(int k=0; k<26; ++k)
                        tmp[k] = a.begin()->first[k] * b.begin()->second;
                    ret[tmp] = 1;
                }

                for(map<vector<int>, long long>::iterator it=ret.begin(); it!=ret.end(); ){
                    map<vector<int>, long long>::iterator it2 = it;
                    ++ it;
                    if(it2->second == 0)
                        ret.erase(it2);
                }

                return ret;
            }
        }
    }

    return calculate(s.substr(1, n-2));
}

int main()
{
    for(;;){
        string s;
        getline(cin, s);
        if(s == ".")
            return 0;

        s = normalize(s);
        map<vector<int>, long long> a = calculate(s);

        for(;;){
            string t;
            getline(cin, t);
            if(t == ".")
                break;

            t = normalize(t);
            map<vector<int>, long long> b = calculate(t);
            if(a == b)
                cout << "yes" << endl;
            else
                cout << "no" << endl;
        }
        cout << '.' << endl;
    }
}

Measured memory_bytes: 1320