#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> pii;

struct V {
  string s;
  V(const string &s) : s(s){
  }
  V operator*(const V &rhs) const {
    string res;
    int i=0,j=0;
    int n = s.size(), m = rhs.s.size();
    while(i<n||j<m) {
      if (i<n && j<m) {
        if (s[i]<rhs.s[j]) res.push_back(s[i++]);
        else res.push_back(rhs.s[j++]);
      } else if(i<n) {
        res.push_back(s[i++]);
      } else {
        res.push_back(rhs.s[j++]);
      }
    }
    return V(res);
  }
  bool operator<(const V &rhs) const {
    return s < rhs.s;
  }
};

typedef map<V, int> MP;

struct P {
  MP mp;
  P() {}
  P(int num) {
    mp[V("")] = num;
  }
  P (char c) {
    mp[V(string(1,c))] = 1;
  }
  P(const MP mp) : mp(mp) {}
  P operator+(const P &rhs) const {
    MP res(mp);
    FOR(it,rhs.mp) {
      res[it->first] += it->second;
    }
    return P(res);
  }
  P operator-(const P &rhs) const {
    MP res(mp);
    FOR(it,rhs.mp)
      res[it->first] -= it->second;
    return P(res);
  }
  P operator*(const P &rhs) const {
    MP res;
    FOR(it,rhs.mp) {
      FOR(jt, mp) {
        res[it->first * jt->first] += it->second * jt->second;
      }
    }
    return P(res);
  }
};

P pow(const P &p1, P p2) {
  assert(p2.mp.size() == 1);
  int num = p2.mp[V("")];
  MP res;
  FOR(it, p1.mp) {
    string s;
    FOR(jt,it->first.s) {
      REP(i,num) s.push_back(*jt);
    }
    int a = 1;
    REP(i,num) a*=it->second;
    res[s] = a;
  }
  return res;
}

P number(const string &s) {
  int num = 0;
  REP(i,s.size()) {
    num *= 10;
    num += s[i]-'0';
  }
  return P(num);
}
int type(char c) {
  if (isdigit(c)) return -1;
  return (int)c;
}
P parse(string s) {
  // テ」ツ?ィテ」ツつ甘」ツ?づ」ツ?暗」ツ?堙・ツ、ツ姪・ツ?エテ」ツ?ョテ」ツつケテ」ツδ堙」ツδシテ」ツつケテ」ツつ津・ツ渉姪」ツつ凝ッツシツ?
  int p1,p2;
  for (p1=0;p1<s.size();++p1) {
    if (s[p1]!=' ') break;
  }
  if (p1==s.size()) return P();
  for (p2=s.size()-1;p2>=0; --p2) {
    if (s[p2]!=' ') break;
  }
  s = s.substr(p1, p2-p1+1);

  if (s[0]=='(') {
    // テ」ツつォテ」ツδε」ツつウテ」ツ?ァテ・ツ崢イテ」ツ?セテ」ツつ古」ツ?淌・ツシツ湘」ツ?ッテ」ツつォテ」ツδε」ツつウテ」ツつ津・ツ渉姪」ツつ?
    bool f = 0;                 
    int cnt = 0;
    REP(i,s.size()-1) {
      if (s[i]=='(') cnt++;
      else if (s[i]==')') cnt--;
      if(cnt==0) f=1;
    }
    if (!f) s = s.substr(1,s.size()-2);
  }
  
  // cout << s << endl;

  
  int cnt = 0;
  int pm = -1;
  int tp = -1;
  REP(i,s.size()) {
    if (s[i]=='(') cnt++;
    else if (s[i]==')') cnt--;
    else if (cnt==0) {
      if ((s[i]=='+'||s[i]=='-')) pm=i;
      if (s[i]=='^') tp=i;
    }
  }
  if (pm==-1) {
    // テ」ツδ催」ツつケテ」ツδ?テ」ツ?ァテ」ツつソテ」ツつ、テ」ツδ療」ツ?古ゥツ?陛」ツ??」ツつづ」ツ?ョテ」ツ?古」ツ?づ」ツつ古」ツ?ーテ」ツ?敕」ツ?禿」ツ?ァテ・ツ按?」ツ?」テ」ツ?ヲテァツゥツ催」ツ?ィテ」ツ?凖」ツつ?
    int pos=-1;
    int cnt = 0;
    REP(i,s.size()-1) {
      if (s[i]=='(') cnt++;
      else if (s[i]==')')cnt--;
      if (cnt==0 && s[i]!=' ' && s[i]!='^') {
        bool ok = 0;
        int j=i+1;
        while(j<s.size()&&s[j]==' ')j++;
        if (j!=i+1){
          if (j<s.size() && s[j] != '^') ok = 1;
        } else {
          if (j<s.size() && s[j]!='^' && !(isdigit(s[i]) && isdigit(s[j]))) ok = 1;
        }
        if (ok) {
          pos = i; break;
        }
      }
    }
    if (pos != -1) {
      P p1 = parse(s.substr(0,pos+1));
      P p2 = parse(s.substr(pos+1));
      return p1*p2;
    }
  }
  if (pm!=-1) {
    P p1 = parse(s.substr(0,pm));
    P p2 = parse(s.substr(pm+1));
    if (s[pm]=='+')return p1+p2;
    else return p1-p2;
  }
  if (tp!=-1) {
    P p1 = parse(s.substr(0,tp));
    P p2 = parse(s.substr(tp+1)); // p2テ」ツ?ッテヲツ閉ーテ・ツュツ療」ツ?ョテ」ツδ湘」ツつコ
    return pow(p1,p2);
  }
  // 1テ」ツ?、テ」ツ?ョテヲツ閉ーテ・ツュツ療」ツ?凝・ツ、ツ嘉ヲツ閉ー
  if (isdigit(s[0])) {
    return number(s);
  } else {
    return P(s[0]);
  }
  
  assert(0);
}

bool eq(const MP &a, const MP &b) {
  MP tmp(a);
  FOR(it, b) tmp[it->first]-=it->second;
  FOR(it,tmp) if (it->second) return 0;
  return 1;
}

int main() {
  string line;
  while(getline(cin,line), line!=".") {
    vector<MP> v;
    do {
      P p = parse(line);
      v.push_back(p.mp);
      // FOR(it, p.mp) {
      //   cout << it->first.s << " " << it->second << endl;
      // }
      // cout << endl;
    } while(getline(cin,line), line!=".");
    for (int i=1; i<v.size(); ++i) {
      if (eq(v[i],v[0])) cout << "yes" << endl;
      else cout << "no" << endl;
    }
    cout << "." << endl;
  }
}