#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << '(' << p.first << ',' << p.second << ')';
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& a) {
  os << '[';
  for (int i = int(0); i < int(a.size()); i++) os << (i ? " " : "") << a[i];
  return os << ']';
}
vector<pair<int, string> > add(const vector<pair<int, string> >& a,
                               const vector<pair<int, string> >& b) {
  map<string, int> f;
  for (auto x : a) {
    sort(begin(x.second), end(x.second));
    f[x.second] += x.first;
  }
  for (auto x : b) {
    sort(begin(x.second), end(x.second));
    f[x.second] += x.first;
  }
  vector<pair<int, string> > c;
  for (auto p : f)
    if (p.second) c.emplace_back(p.second, p.first);
  return c;
}
vector<pair<int, string> > mul(const vector<pair<int, string> >& a,
                               const vector<pair<int, string> >& b) {
  map<string, int> f;
  for (auto x : a)
    for (auto y : b) {
      string s = x.second + y.second;
      sort(begin(s), end(s));
      f[s] += x.first * y.first;
    }
  vector<pair<int, string> > c;
  for (auto p : f)
    if (p.second) c.emplace_back(p.second, p.first);
  return c;
}
vector<pair<int, string> > pow(const vector<pair<int, string> >& a, int r) {
  vector<pair<int, string> > b(1, pair<int, string>(1, ""));
  for (int i = int(0); i < int(r); i++) b = mul(b, a);
  return b;
}
pair<vector<pair<int, string> >, int> parse_expr(string f, int i);
pair<vector<pair<int, string> >, int> parse_fact(string f, int i) {
  while (i < f.size() && f[i] == ' ') i++;
  vector<pair<int, string> > x;
  if (f[i] == '(') {
    i++;
    tie(x, i) = parse_expr(f, i);
    while (i < f.size() && f[i] == ' ') i++;
    i++;
  } else if (isdigit(f[i])) {
    int n = 0;
    while (i < f.size() && isdigit(f[i])) n = n * 10 + f[i++] - '0';
    x.emplace_back(n, "");
  } else if (isalpha(f[i])) {
    x.emplace_back(1, f.substr(i, 1));
    i++;
  }
  while (i < f.size() && f[i] == ' ') i++;
  if (i < f.size() && f[i] == '^') {
    i++;
    while (i < f.size() && f[i] == ' ') i++;
    int n = 0;
    while (i < f.size() && isdigit(f[i])) {
      n = n * 10 + f[i] - '0';
      i++;
    }
    x = pow(x, n);
  }
  return make_pair(x, i);
}
pair<vector<pair<int, string> >, int> parse_term(string f, int i) {
  while (i < f.size() && f[i] == ' ') i++;
  vector<pair<int, string> > x;
  tie(x, i) = parse_fact(f, i);
  while (i < f.size() && f[i] == ' ') i++;
  while (i < f.size() && (f[i] == '(' || isdigit(f[i]) || isalpha(f[i]))) {
    vector<pair<int, string> > y;
    tie(y, i) = parse_fact(f, i);
    x = mul(x, y);
    while (i < f.size() && f[i] == ' ') i++;
  }
  return make_pair(x, i);
}
pair<vector<pair<int, string> >, int> parse_expr(string f, int i) {
  while (i < f.size() && f[i] == ' ') i++;
  vector<pair<int, string> > x;
  tie(x, i) = parse_term(f, i);
  while (i < f.size() && f[i] == ' ') i++;
  while (i < f.size() && (f[i] == '+' || f[i] == '-')) {
    i++;
    vector<pair<int, string> > y;
    tie(y, i) = parse_term(f, i);
    x = add(x, y);
    while (i < f.size() && f[i] == ' ') i++;
  }
  return make_pair(x, i);
}
int main() {
  for (string line; getline(cin, line) && line != ".";) {
    vector<string> fs;
    do {
      fs.push_back(line);
      getline(cin, line);
    } while (line != ".");
    auto t0 = parse_expr(fs[0], 0).first;
    for (int i = int(1); i < int(fs.size()); i++)
      cout << (parse_expr(fs[i], 0).first == t0 ? "yes" : "no") << endl;
    cout << '.' << endl;
  }
}
