#include <bits/stdc++.h>
using namespace std;
string s;
int p;
unsigned long long A[300];
unsigned long long bnf();
unsigned long long get_num() {
  if (s[p] == '(') {
    p++;
    unsigned long long res = bnf();
    p++;
    return res;
  }
  if ('a' <= s[p] && s[p] <= 'z') return A[s[p++]];
  unsigned long long num = 0;
  while ('0' <= s[p] && s[p] <= '9') num = num * 10 + s[p] - '0', p++;
  return num;
}
unsigned long long bnf3() {
  unsigned long long res = get_num();
  while (p < s.size()) {
    if (s[p] == '^') {
      p++;
      unsigned long long r = get_num();
      unsigned long long tmp = 1;
      for (int i = 0; i < r; i++) tmp *= res;
      res = tmp;
    } else
      break;
  }
  return res;
}
unsigned long long bnf2() {
  unsigned long long res = bnf3();
  while (p < s.size()) {
    if (s[p] == '*') {
      p++;
      unsigned long long r = bnf3();
      res *= r;
    } else
      break;
  }
  return res;
}
unsigned long long bnf() {
  unsigned long long res = bnf2();
  while (p < s.size()) {
    if (s[p] == '+') {
      p++;
      unsigned long long r = bnf2();
      res += r;
    } else if (s[p] == '-') {
      p++;
      unsigned long long r = bnf2();
      res -= r;
    } else
      break;
  }
  return res;
}
void change() {
  for (int i = 0; i < s.size(); i++)
    if ((s[i] == ')' || ('a' <= s[i] && s[i] <= 'z') ||
         ('0' <= s[i] && s[i] <= '9')))
      if ((s[i + 1] == '(' || ('a' <= s[i + 1] && s[i + 1] <= 'z') ||
           ('0' <= s[i + 1] && s[i + 1] <= '9')))
        if (!('0' <= s[i] && s[i] <= '9' && '0' <= s[i + 1] && s[i + 1] <= '9'))
          s = s.substr(0, i + 1) + '*' + s.substr(i + 1);
  for (int i = 0; i < s.size(); i++)
    if (s[i] == ' ')
      while (s[i] == ' ' && i + 1 < s.size() && s[i + 1] == ' ')
        s.erase(s.begin() + i);
  if (s[0] == ' ') s.erase(s.begin());
  if (s[s.size() - 1] == ' ') s.erase(s.begin() + s.size() - 1);
  for (int i = 0; i < s.size(); i++)
    if (s[i] == ' ')
      if ((s[i - 1] == ')' || ('a' <= s[i - 1] && s[i - 1] <= 'z') ||
           ('0' <= s[i - 1] && s[i - 1] <= '9')))
        if ((s[i + 1] == '(' || ('a' <= s[i + 1] && s[i + 1] <= 'z') ||
             ('0' <= s[i + 1] && s[i + 1] <= '9')))
          s[i] = '*';
  for (int i = 0; i < s.size(); i++)
    if (s[i] == ' ') s.erase(s.begin() + i), i--;
}
int main() {
  for (int i = 0; i < 300; i++) A[i] = rand();
  while (1) {
    getline(cin, s);
    if (s == ".") break;
    change();
    p = 0;
    unsigned long long ans = bnf();
    while (1) {
      getline(cin, s);
      change();
      p = 0;
      unsigned long long r = bnf();
      if (s == ".") {
        cout << "." << endl;
        break;
      }
      cout << (ans == r ? "yes" : "no") << endl;
    }
  }
  return 0;
}
