#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

struct Polynomial{
    map<string, int> terms;
    Polynomial(int a){
        terms[""] = a;
    }
    Polynomial(string s){
        terms[s] = 1;
    }
    Polynomial(){}
    static void erase_zero(Polynomial &a){
        for(auto it=a.terms.begin(); it!=a.terms.end();){
            if(it->second == 0){
                it = a.terms.erase(it);
            }else{
                it++;
            }
        }
    }
    Polynomial operator +(const Polynomial &a) const{
        Polynomial res = *this;
        for(const auto &p: a.terms){
            res.terms[p.first] += p.second;
        }
        erase_zero(res);
        return res;
    }
    Polynomial operator -(const Polynomial &a) const{
        Polynomial res = *this;
        for(const auto &p: a.terms){
            res.terms[p.first] -= p.second;
        }
        erase_zero(res);
        return res;
    }
    Polynomial operator *(const Polynomial &a) const{
        Polynomial res;
        for(const auto &p: terms){
            for(const auto &q: a.terms){
                string key = p.first + q.first;
                sort(key.begin(), key.end());
                res.terms[key] += p.second * q.second;
            }
        }
        erase_zero(res);
        return res;
    }
    bool operator ==(const Polynomial &a) const{
        return terms == a.terms;
    }
};

int getnum(int &p, const string &s){
    int num = 0;
    while(p<(int)s.length() and '0'<=s[p] and s[p]<='9'){
        num *= 10;
        num += s[p]-'0';
        p++;
    }
    return num;
}
Polynomial parse(int &p, const string &s){
    Polynomial res;
    Polynomial term(1);
    int sign = 1;
    while(1){
        if(p<(int)s.length() and s[p] == ' '){
            p++;
            continue;
        }
        if(p>=(int)s.length() or s[p]=='+' or s[p]=='-' or s[p]==')'){
            if(sign == 1) res = res + term;
            else res = res - term;
            term = Polynomial(1);
            if(p>=(int)s.length() or s[p]==')'){
                p++;
                return res;
            }
            if(s[p] == '+') sign = 1;
            else sign = -1;
            p++;
            continue;
        }
        if('0'<=s[p] and s[p]<='9'){
            term = term * Polynomial(getnum(p, s));
            continue;
        }
        if('a'<=s[p] and s[p]<='z'){
            char var = s[p];
            p++;
            int num = 1;
            while(p<(int)s.length() and s[p]==' '){
                p++;
            }
            if(p<(int)s.length() and s[p]=='^'){
                p++;
                while(s[p] == ' ') p++;
                num = getnum(p, s);
            }
            term = term * Polynomial(string(num, var));
            continue;
        }
        if(s[p] == '('){
            p++;
            term = term * parse(p, s);
            continue;
        }
    }
}

int main(){
    while(1){
        vector<string> s;
        string t;
        while(getline(cin, t), t!="."){
            s.push_back(t);
        }
        if(s.empty()) break;

        vector<Polynomial> p;
        for(auto ss: s){
            int i=0;
            p.push_back(parse(i, ss));
        }
        for(int i=1; i<(int)p.size(); i++){
            if(p[i] == p[0]){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }
        cout << "." << endl;
    }
    return 0;
}

