#include <bits/stdc++.h>
using namespace std;
char s[1234567];
char *p;
map<map<char, int>, int> exp();
map<map<char, int>, int> mul() {
  while (*p == ' ') {
    p++;
  }
  if (isdigit(*p)) {
    map<map<char, int>, int> e;
    e[map<char, int>()] = strtol(p, &p, 10);
    return e;
  } else if (*p == '(') {
    p++;
    auto r = exp();
    while (*p == ' ') {
      p++;
    }
    p++;
    return r;
  } else {
    char c = *p;
    p++;
    while (*p == ' ') {
      p++;
    }
    int pw;
    if (*p != '^') {
      pw = 1;
    } else {
      p++;
      pw = strtol(p, &p, 10);
    }
    map<char, int> v;
    v[c] = pw;
    map<map<char, int>, int> e;
    e[v] = 1;
    return e;
  }
}
map<map<char, int>, int> term() {
  auto l = mul();
  for (;;) {
    while (*p == ' ') {
      p++;
    }
    if (!isalnum(*p) && *p != '(') break;
    auto lo = l;
    l.clear();
    auto r = mul();
    for (auto &e : lo) {
      for (auto &f : r) {
        map<char, int> v;
        for (auto &ee : e.first) {
          v[ee.first] += ee.second;
        }
        for (auto &ff : f.first) {
          v[ff.first] += ff.second;
        }
        l[v] += e.second * f.second;
      }
    }
  }
  return l;
}
map<map<char, int>, int> exp() {
  auto l = term();
  for (;;) {
    while (*p == ' ') {
      p++;
    }
    int f;
    if (*p == '+') {
      f = 1;
    } else if (*p == '-') {
      f = -1;
    } else {
      break;
    }
    auto r = term();
    for (auto &e : r) {
      l[e.first] += f * e.second;
    }
  }
  return l;
}
map<map<char, int>, int> startexp() {
  p = s;
  auto r = exp();
  for (auto it = r.begin(); it != r.end();) {
    if (it->second == 0) {
      it = r.erase(it);
    } else {
      it++;
    }
  }
  return r;
}
int main() {
  while (cin.getline(s, sizeof s), s[0] != '.') {
    auto ans = startexp();
    while (cin.getline(s, sizeof s), s[0] != '.') {
      auto c = startexp();
      cout << ((ans == c) ? "yes" : "no") << endl;
    }
    cout << "." << endl;
  }
}
