#include <bits/stdc++.h>
using namespace std;
int var[128];
long long expr(const string &, int &);
long long term(const string &, int &);
long long factor(const string &, int &);
long long primary(const string &, int &);
long long number(const string &, int &);
long long expr(const string &s, int &idx) {
  long long a = term(s, idx);
  while (idx < s.length() && (s[idx] == '+' || s[idx] == '-')) {
    char op = s[idx++];
    if (op == '+')
      a += term(s, idx);
    else if (op == '-')
      a -= term(s, idx);
  }
  return a;
}
long long term(const string &s, int &idx) {
  long long a = factor(s, idx);
  while (idx < s.length() && s[idx] == '*') {
    idx++;
    a *= factor(s, idx);
  }
  return a;
}
long long factor(const string &s, int &idx) {
  long long a = primary(s, idx);
  if (idx < s.length() && s[idx] == '^') {
    idx++;
    long long b = primary(s, idx);
    long long apowb = 1;
    for (int i = 0; i < (b); i++) apowb *= a;
    a = apowb;
  }
  return a;
}
long long primary(const string &s, int &idx) {
  long long a;
  if (s[idx] == '(') {
    idx++;
    a = expr(s, idx);
    idx++;
  } else
    a = number(s, idx);
  return a;
}
long long number(const string &s, int &idx) {
  long long a;
  if (isalpha(s[idx]))
    a = var[s[idx++]];
  else {
    for (a = 0; idx < s.length() && isdigit(s[idx]); idx++)
      a = 10 * a + (s[idx] - '0');
  }
  return a;
}
long long parse(const string &s) {
  int idx = 0;
  return expr(s, idx);
}
void normalize(string &s) {
  string t;
  int n = s.length();
  for (int i = 0; i < (n); i++)
    if (s[i] != ' ') {
      if (i > 0 && s[i - 1] == ' ' && !t.empty()) {
        if (isdigit(*t.rbegin()) && isdigit(s[i])) t += '*';
      }
      t += s[i];
    }
  s.clear();
  n = t.length();
  for (int i = 0; i < (n); i++) {
    if (i > 0) {
      if (isdigit(t[i - 1]) && isalpha(t[i]) ||
          isdigit(t[i - 1]) && t[i] == '(' ||
          isalpha(t[i - 1]) && isdigit(t[i]) ||
          isalpha(t[i - 1]) && isalpha(t[i]) ||
          isalpha(t[i - 1]) && t[i] == '(' ||
          t[i - 1] == ')' && isdigit(t[i]) ||
          t[i - 1] == ')' && isalpha(t[i]) || t[i - 1] == ')' && t[i] == '(')
        s += '*';
    }
    s += t[i];
  }
}
int main() {
  for (string ex0; getline(cin, ex0), ex0 != ".";) {
    normalize(ex0);
    while (1) {
      string ex;
      getline(cin, ex);
      if (ex == ".") break;
      normalize(ex);
      bool ok = true;
      for (int _ = 0; _ < (10); _++) {
        for (int c = 'a'; c <= 'z'; c++) var[c] = rand() % 7;
        if (parse(ex0) != parse(ex)) {
          ok = false;
          break;
        }
      }
      puts(ok ? "yes" : "no");
    }
    puts(".");
  }
  return 0;
}
