#include <bits/stdc++.h>
int ppow(int base, int iexp) {
  int res = 1;
  for (int dbl = base; iexp; iexp >>= 1) {
    if (iexp & 1) res *= dbl;
    dbl *= dbl;
  }
  return res;
}
int apply(int lhs, char op, int rhs) {
  switch (op) {
    case '+':
      return lhs + rhs;
    case '-':
      return lhs - rhs;
    case '*':
      return lhs * rhs;
    case '^':
      return ppow(lhs, rhs);
    default:
      assert(false);
  }
}
int fourt(const std::string &s, size_t &i, const std::vector<int> &vars,
          const std::vector<std::string> &ops = {"+-", "*", "^", ""},
          size_t prec = 0) {
  if (ops[prec].empty()) {
    if (s[i] == '(') {
      int tmp = fourt(s, ++i, vars, ops, 0);
      assert(s[i] == ')');
      ++i;
      return tmp;
    }
    if (isalpha(s[i])) {
      return vars[s[i++] - 'a'];
    }
    int res = 0;
    while (s[i] >= '0' && s[i] <= '9') res = res * 10 + s[i++] - '0';
    return res;
  }
  int res = fourt(s, i, vars, ops, prec + 1);
  while (i < s.length()) {
    char op = s[i];
    if (!std::count(ops[prec].begin(), ops[prec].end(), op)) break;
    int tmp = fourt(s, ++i, vars, ops, prec + 1);
    res = apply(res, op, tmp);
  }
  return res;
}
int parse(const std::string &s, const std::vector<int> &vars) {
  size_t i = 0;
  return fourt(s, i, vars);
}
std::string normalize(const std::string &s) {
  std::string res;
  enum { NONE, PAREN, FACTOR, OPERATOR } last = NONE;
  for (size_t i = 0; i < s.length(); ++i) {
    if (s[i] == '(') {
      if (last == FACTOR) {
        res += '*';
      }
      res += '(';
      last = PAREN;
    } else if (s[i] == ')') {
      res += ')';
      last = FACTOR;
    } else if (isalnum(s[i])) {
      if (last == FACTOR) {
        res += '*';
      }
      res += s[i];
      if (isdigit(s[i])) {
        while (i + 1 < s.length() && isdigit(s[i + 1])) res += s[++i];
      }
      last = FACTOR;
    } else if (!isspace(s[i])) {
      res += s[i];
      last = OPERATOR;
    }
  }
  return res;
}
std::mt19937 rsk(0315);
int testcase_ends() {
  char buf[96];
  fgets(buf, sizeof buf, stdin);
  std::string s = buf;
  if (s == ".\n") return 1;
  s = normalize(s);
  while (true) {
    fgets(buf, sizeof buf, stdin);
    std::string t = buf;
    if (t == ".\n") {
      printf(".\n");
      return 0;
    }
    t = normalize(t);
    bool yes = true;
    for (int i = 0; i < 810; ++i) {
      std::vector<int> vars(26);
      for (int j = 0; j < 26; ++j) vars[j] = rsk() % 10;
      if (parse(s, vars) != parse(t, vars)) yes = false;
    }
    printf("%s\n", yes ? "yes" : "no");
  }
}
int main() {
  while (!testcase_ends()) {
  }
}
