#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = MOD + 1;
const long double EPS = 1e-7;
template <class T>
T& chmin(T& a, const T& b) {
  return a = min(a, b);
}
template <class T>
T& chmax(T& a, const T& b) {
  return a = max(a, b);
}
vector<vector<long long>> rnd(10, vector<long long>(26));
int p, var;
long long sum(string& s);
long long num(string& s) {
  long long res = 0;
  while (isdigit(s[p])) {
    res *= 10;
    res += s[p] - '0';
    p++;
  }
  return res;
}
long long unit(string& s) {
  long long res;
  while (s[p] == ' ') p++;
  if (s[p] == '(') {
    p++;
    res = sum(s);
    p++;
  } else if (isdigit(s[p]))
    res = num(s);
  else if (islower(s[p])) {
    res = rnd[var][s[p] - 'a'];
    p++;
  } else
    assert(false);
  return res;
}
long long pow(string& s) {
  long long lhs = unit(s);
  while (s[p] == '^') {
    p++;
    while (s[p] == ' ') p++;
    long long rhs = pow(s);
    long long tmp = 1;
    for (int i = (int)(0); i < (int)(rhs); i++) {
      tmp *= lhs;
    }
    lhs = tmp;
  }
  return lhs;
}
long long mul(string& s) {
  long long lhs = pow(s);
  while (s[p] == '*') {
    p++;
    long long rhs;
    rhs = pow(s);
    lhs *= rhs;
  }
  return lhs;
}
long long sum(string& s) {
  long long lhs = mul(s);
  while (s[p] == '+' || s[p] == '-') {
    if (s[p] == '+') {
      p++;
      long long rhs = mul(s);
      lhs += rhs;
    } else {
      p++;
      long long rhs = mul(s);
      lhs -= rhs;
    }
  }
  return lhs;
}
long long parse(string& s) {
  p = 0;
  return sum(s);
}
bool isMulti(char a, char b, bool flag) {
  if (flag && isdigit(a) && isdigit(b)) return true;
  if (isdigit(a) && islower(b)) return true;
  if (islower(a) && islower(b)) return true;
  if (islower(a) && isdigit(b)) return true;
  if ((a == ')') && (b == '(')) return true;
  if ((a == ')') && (isdigit(b) || islower(b))) return true;
  if ((isdigit(a) || islower(a)) && (b == '(')) return true;
  return false;
}
string make(string s) {
  string tmp, res;
  stringstream ss;
  ss << s;
  vector<string> buf;
  while (!(ss >> s).fail()) buf.push_back(s);
  for (int i = (int)(0); i < (int)(buf.size()); i++) {
    if (i + 1 < buf.size() && isMulti(buf[i].back(), buf[i + 1][0], true)) {
      tmp += (buf[i] + "*");
    } else
      tmp += buf[i];
  }
  for (int i = (int)(0); i < (int)(tmp.size()); i++) {
    if (i + 1 < tmp.size() && isMulti(tmp[i], tmp[i + 1], false))
      res += string(1, tmp[i]) + "*";
    else
      res += string(1, tmp[i]);
  }
  return res;
}
int main() {
  string s, t;
  for (int i = (int)(0); i < (int)(10); i++)
    for (int j = (int)(0); j < (int)(26); j++) rnd[i][j] = rand() % 20;
  while (getline(cin, s), s != ".") {
    string s_ = make(s);
    while (getline(cin, t), t != ".") {
      string t_ = make(t);
      bool f = true;
      for (var = 0; var < 10 && f; var++) {
        long long lhs = parse(s_);
        long long rhs = parse(t_);
        if (lhs != rhs) f = false;
      }
      puts(f ? "yes" : "no");
    }
    puts(".");
  }
  return 0;
}
