#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
unsigned long xor128() {
  static unsigned long x = 123456789, y = 362436069, z = 521288629,
                       w = 88675123;
  unsigned long t;
  t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
long long power(long long a, long long b) {
  long long ret = 1;
  long long tmp = a;
  while (b > 0) {
    if (b & 1) {
      ret *= tmp;
      ret %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
    b >>= 1;
  }
  return ret;
}
string ope = "+-*^";
vector<long long> variable(256);
string normalize(string s) {
  int n = s.size();
  string t = s.substr(0, 1);
  for (int i = 1; i < n; ++i) {
    if ((isalnum(s[i - 1]) || s[i - 1] == ')') &&
        (isalnum(s[i]) || s[i] == '(') && !(isdigit(s[i - 1]) && isdigit(s[i])))
      t += ' ';
    t += s[i];
  }
  s = t;
  n = s.size();
  t = "";
  for (int i = 0; i < n; ++i) {
    if (s[i] == ' ') {
      if (ope.find(s[i - 1]) == string::npos &&
          ope.find(s[i + 1]) == string::npos)
        t += '*';
    } else {
      t += s[i];
    }
  }
  return t;
}
long long calculate(string s) {
  int n = s.size();
  bool isNum = true;
  for (int i = 0; i < n; ++i) {
    if (!isdigit(s[i])) isNum = false;
  }
  if (isNum) {
    istringstream iss(s);
    long long ret;
    iss >> ret;
    return ret % MOD;
  }
  if (n == 1) return variable[s[0]];
  for (int i = 0; i < 4; ++i) {
    int bracket = 0;
    for (int j = n - 1; j >= 0; --j) {
      if (s[j] == '(')
        ++bracket;
      else if (s[j] == ')')
        --bracket;
      else if (s[j] == ope[i] && bracket == 0) {
        string t1 = s.substr(0, j);
        string t2 = s.substr(j + 1);
        if (i == 0)
          return (calculate(t1) + calculate(t2)) % MOD;
        else if (i == 1)
          return (calculate(t1) - calculate(t2) + MOD) % MOD;
        else if (i == 2)
          return (calculate(t1) * calculate(t2)) % MOD;
        else
          return power(calculate(t1), calculate(t2));
      }
    }
  }
  return calculate(s.substr(1, n - 2));
}
string solve(string s, string t) {
  s = normalize(s);
  t = normalize(t);
  for (int i = 0; i < 50; ++i) {
    for (char c = 'a'; c <= 'z'; ++c) variable[c] = xor128() % MOD;
    long long x = calculate(s);
    long long y = calculate(t);
    if (x != y) return "no";
  }
  return "yes";
}
int main() {
  for (;;) {
    string s;
    getline(cin, s);
    if (s == ".") return 0;
    for (;;) {
      string t;
      getline(cin, t);
      if (t == ".") break;
      cout << solve(s, t) << endl;
    }
    cout << '.' << endl;
  }
}
