#include <bits/stdc++.h>
using namespace std;
string normalize(string s) {
  string t = "";
  for (long long i = 0; i < (long long)(s.size()); i++) {
    if (s[i] != ' ')
      t += s[i];
    else if (i + 1 == s.size() || s[i + 1] != ' ')
      t += s[i];
  }
  for (long long i = 0; i < (long long)(t.size() - 1); i++)
    assert(t[i] != ' ' || t[i + 1] != ' ');
  string u = "";
  for (long long i = 0; i < (long long)(t.size()); i++) {
    char ch = t[i];
    if (ch != ' ') {
      u += ch;
      continue;
    }
    if (!(i - 1 < 0 || t[i - 1] == '(' || t[i - 1] == '-' || t[i - 1] == '+' ||
          t[i - 1] == '^') &&
        !(i + 1 >= t.size() || t[i + 1] == ')' || t[i + 1] == '-' ||
          t[i + 1] == '+' || t[i + 1] == '^'))
      u += ' ';
  }
  for (long long i = 0; i < (long long)(u.size()); i++)
    if (u[i] == ' ') u[i] = '*';
  string ret = "";
  for (long long i = 0; i < (long long)(u.size()); i++) {
    ret += u[i];
    if (i + 1 >= u.size()) continue;
    if (isdigit(u[i])) {
      if (u[i + 1] == '(' || isalpha(u[i + 1])) ret += '*';
    }
    if (isalpha(u[i])) {
      if (u[i + 1] == '(' || isdigit(u[i + 1]) || isalpha(u[i + 1])) ret += '*';
    }
  }
  return ret;
}
vector<array<long long, 27> > E(string::const_iterator &beg);
long long dig(string::const_iterator &beg) {
  assert(isdigit(*beg));
  string res = "";
  while (isdigit(*beg)) {
    res += *beg;
    beg++;
  }
  return stoll(res);
}
vector<array<long long, 27> > P(string::const_iterator &beg) {
  if (isdigit(*beg)) {
    long long res = dig(beg);
    array<long long, 27> ret;
    ret[0] = res;
    for (long long i = 1; i < ret.size(); i++) ret[i] = 0;
    return vector<array<long long, 27> >(1, ret);
  } else {
    assert(isalpha(*beg));
    char ch = *beg;
    beg++;
    if (*beg == '^') {
      beg++;
      long long t = dig(beg);
      array<long long, 27> ret;
      for (long long i = 0; i < (long long)(ret.size()); i++) {
        if (i == ch - 'a' + 1)
          ret[i] = t;
        else
          ret[i] = 0;
      }
      ret[0] = 1;
      return vector<array<long long, 27> >(1, ret);
    } else {
      array<long long, 27> ret;
      for (long long i = 0; i < (long long)(ret.size()); i++) {
        if (i == ch - 'a' + 1)
          ret[i] = 1;
        else
          ret[i] = 0;
      }
      ret[0] = 1;
      return vector<array<long long, 27> >(1, ret);
    }
  }
}
array<long long, 27> mul(array<long long, 27> a, array<long long, 27> b) {
  array<long long, 27> ret;
  ret[0] = a[0] * b[0];
  for (long long i = 1; i < a.size(); i++) {
    ret[i] = a[i] + b[i];
  }
  return ret;
}
vector<array<long long, 27> > mulEX(vector<array<long long, 27> > a,
                                    vector<array<long long, 27> > b) {
  vector<array<long long, 27> > ret;
  for (long long i = 0; i < (long long)(a.size()); i++) {
    for (long long j = 0; j < (long long)(b.size()); j++) {
      ret.push_back(mul(a[i], b[j]));
    }
  }
  return ret;
}
vector<array<long long, 27> > T(string::const_iterator &beg) {
  vector<array<long long, 27> > ret;
  if (*beg == '(') {
    beg++;
    ret = E(beg);
    beg++;
  } else {
    assert(isdigit(*beg) || isalpha(*beg));
    ret = P(beg);
  }
  while (*beg == '*') {
    beg++;
    vector<array<long long, 27> > t = T(beg);
    ret = mulEX(ret, t);
  }
  return ret;
}
bool isSame(array<long long, 27> a, array<long long, 27> b) {
  for (long long i = 1; i < a.size(); i++) {
    if (a[i] != b[i]) return false;
  }
  return true;
}
vector<array<long long, 27> > E(string::const_iterator &beg) {
  vector<array<long long, 27> > res = T(beg);
  while (*beg == '+' || *beg == '-') {
    if (*beg == '+') {
      beg++;
      vector<array<long long, 27> > t = T(beg);
      for (long long i = 0; i < (long long)(t.size()); i++) {
        bool f = false;
        for (long long j = 0; j < (long long)(res.size()); j++) {
          if (isSame(t[i], res[j])) {
            f = true;
            res[j][0] += t[i][0];
            break;
          }
        }
        if (!f) {
          res.push_back(t[i]);
        }
      }
    } else if (*beg == '-') {
      beg++;
      vector<array<long long, 27> > t = T(beg);
      for (long long i = 0; i < (long long)(t.size()); i++) {
        bool f = false;
        for (long long j = 0; j < (long long)(res.size()); j++) {
          if (isSame(t[i], res[j])) {
            f = true;
            res[j][0] -= t[i][0];
            break;
          }
        }
        if (!f) {
          t[i][0] *= -1;
          res.push_back(t[i]);
        }
      }
    }
  }
  return res;
}
bool isMatch(vector<array<long long, 27> > a, vector<array<long long, 27> > b) {
  sort((a).begin(), (a).end());
  sort((b).begin(), (b).end());
  if (a == b)
    return true;
  else
    return false;
}
void output(vector<vector<array<long long, 27> > > ans) {
  for (long long i = 0; i < (long long)(ans.size()); i++) {
    for (long long j = 0; j < (long long)(ans[i].size()); j++) {
      for (long long k = 0; k < (long long)(ans[i][j].size()); k++) {
        cout << ans[i][j][k] << " ";
      }
      cout << endl;
    }
    cout << endl << endl;
  }
}
signed main() {
  assert(normalize("(a - b) (0-b+a) - 1a ^ 2 - b ^ 2") ==
         "(a-b)*(0-b+a)-1*a^2-b^2");
  while (1) {
    vector<string> vs;
    string s;
    while (getline(cin, s) && s != ".") {
      vs.push_back(s);
    }
    if (vs.size() == 0) break;
    for (long long i = 0; i < (long long)(vs.size()); i++)
      vs[i] = normalize(vs[i]);
    vector<vector<array<long long, 27> > > ans;
    for (long long i = 0; i < (long long)(vs.size()); i++) {
      string::const_iterator beg = vs[i].begin();
      vector<array<long long, 27> > res = E(beg);
      ans.push_back(res);
    }
    for (long long i = 1; i < ans.size(); i++) {
      if (isMatch(ans[0], ans[i])) {
        cout << "yes" << endl;
      } else
        cout << "no" << endl;
    }
    cout << "." << endl;
  }
}
