#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(T begin, T end) {
  for (T i = begin; i != end; ++i) cerr << *i << " ";
  cerr << endl;
}
inline bool valid(int x, int y, int W, int H) {
  return (x >= 0 && y >= 0 && x < W && y < H);
}
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool is_operator(char c) {
  string opes = "+-^*";
  for (int i = (0); i < (int)(opes.size()); ++i)
    if (c == opes[i]) return true;
  return false;
}
string preprocessing(string s) {
  stringstream ss(s);
  string res;
  ss >> res;
  while (ss >> s) {
    char a = res[res.size() - 1];
    char b = s[0];
    if (is_operator(a) || is_operator(b))
      res += s;
    else
      res += "*" + s;
  }
  for (int i = (0); i < (int)(res.size() - 1); ++i) {
    if ((isalpha(res[i]) && isalpha(res[i + 1])) ||
        (isdigit(res[i]) && isalpha(res[i + 1])) ||
        (isalpha(res[i]) && isdigit(res[i + 1]))) {
      res.insert(++i, "*");
    }
  }
  return res;
}
map<char, int> mul(map<char, int> x, map<char, int> y) {
  for (__typeof((y).begin()) it = (y).begin(); it != (y).end(); ++it) {
    x[it->first] += it->second;
  }
  return x;
}
struct Result {
  map<map<char, int>, int> value;
  int p;
  Result(map<map<char, int>, int> v, int p) : value(v), p(p) {}
};
Result expression(const string& s, int p);
Result term(const string& s, int p);
Result term_pow(const string& s, int p);
Result factor(const string& s, int p);
Result expression(const string& s, int p) {
  Result r = term(s, p);
  while (s[r.p] == '+' || s[r.p] == '-') {
    Result t = term(s, r.p + 1);
    for (__typeof((t.value).begin()) it = (t.value).begin();
         it != (t.value).end(); ++it) {
      if (s[r.p] == '+') r.value[it->first] += it->second;
      if (s[r.p] == '-') r.value[it->first] -= it->second;
    }
    r.p = t.p;
  }
  return r;
}
Result term(const string& s, int p) {
  Result r = factor(s, p);
  while (s[r.p] == '*') {
    Result t = factor(s, r.p + 1);
    map<map<char, int>, int> new_val;
    for (__typeof((r.value).begin()) it1 = (r.value).begin();
         it1 != (r.value).end(); ++it1)
      for (__typeof((t.value).begin()) it2 = (t.value).begin();
           it2 != (t.value).end(); ++it2) {
        new_val[mul(it1->first, it2->first)] += it1->second * it2->second;
      }
    r.value = new_val;
    r.p = t.p;
  }
  return r;
}
Result factor(const string& s, int p) {
  if (s[p] == '(') {
    Result r = expression(s, p + 1);
    assert(s[r.p] == ')');
    r.p++;
    return r;
  } else if (isdigit(s[p])) {
    int val = 0;
    while (isdigit(s[p])) {
      val = val * 10 + s[p++] - '0';
    }
    map<map<char, int>, int> expr;
    expr[map<char, int>()] = val;
    return Result(expr, p);
  } else if (isalpha(s[p])) {
    char c = s[p++];
    if (s[p] == '^') {
      p++;
      int val = 0;
      while (isdigit(s[p])) {
        val = val * 10 + s[p++] - '0';
      }
      map<map<char, int>, int> expr;
      map<char, int> v;
      v[c] = val;
      expr[v] = 1;
      return Result(expr, p);
    } else {
      map<map<char, int>, int> expr;
      map<char, int> v;
      v[c] = 1;
      expr[v] = 1;
      return Result(expr, p);
    }
  } else if (s[p] == '-') {
    Result r = factor(s, p + 1);
    for (__typeof((r.value).begin()) it = (r.value).begin();
         it != (r.value).end(); ++it) {
      r.value[it->first] = -it->second;
    }
    return r;
  } else if (s[p] == '+') {
    Result r = factor(s, p + 1);
    return r;
  } else {
    assert(false);
  }
}
string to_str(const map<char, int>& v) {
  string res;
  for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it) {
    if (res != "") res += "*";
    stringstream ss;
    ss << it->first;
    if (it->second != 1) {
      ss << "^";
      ss << it->second;
    }
    res += ss.str();
  }
  return res;
}
void print(map<map<char, int>, int>& expr) {
  for (__typeof((expr).begin()) it = (expr).begin(); it != (expr).end(); ++it) {
    printf("%+d%s", it->second, to_str(it->first).c_str());
  }
  putchar('\n');
}
bool equal(map<map<char, int>, int> e1, map<map<char, int>, int> e2) {
  for (__typeof((e1).begin()) it = (e1).begin(); it != (e1).end(); ++it) {
    if (e1[it->first] != e2[it->first]) return false;
  }
  for (__typeof((e2).begin()) it = (e2).begin(); it != (e2).end(); ++it) {
    if (e1[it->first] != e2[it->first]) return false;
  }
  return true;
}
int main() {
  string line;
  while (getline(cin, line) && line != ".") {
    line = preprocessing(line);
    Result r = expression(line, 0);
    map<map<char, int>, int> expr = r.value;
    while (getline(cin, line) && line != ".") {
      line = preprocessing(line);
      Result r = expression(line, 0);
      map<map<char, int>, int> expr2 = r.value;
      if (equal(expr, expr2))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
    cout << "." << endl;
  }
  return 0;
}
