#include <bits/stdc++.h>
using namespace std;
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;
}
map<vector<int>, 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) {
    map<vector<int>, long long> ret;
    long long tmp = 0;
    for (int i = 0; i < n; ++i) {
      tmp *= 10;
      tmp += s[i] - '0';
    }
    ret[vector<int>(26, 0)] = tmp;
    return ret;
  }
  if (n == 1) {
    map<vector<int>, long long> ret;
    vector<int> tmp(26, 0);
    tmp[s[0] - 'a'] = 1;
    ret[tmp] = 1;
    return ret;
  }
  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);
        map<vector<int>, long long> a = calculate(t1);
        map<vector<int>, long long> b = calculate(t2);
        map<vector<int>, long long> ret;
        if (i == 0) {
          ret = a;
          for (auto it = b.begin(); it != b.end(); ++it)
            ret[it->first] += it->second;
        } else if (i == 1) {
          ret = a;
          for (auto it = b.begin(); it != b.end(); ++it)
            ret[it->first] -= it->second;
        } else if (i == 2) {
          for (auto it1 = a.begin(); it1 != a.end(); ++it1) {
            for (auto it2 = b.begin(); it2 != b.end(); ++it2) {
              vector<int> tmp(26);
              for (int k = 0; k < 26; ++k)
                tmp[k] = it1->first[k] + it2->first[k];
              ret[tmp] += it1->second * it2->second;
            }
          }
        } else {
          vector<int> tmp(26);
          for (int k = 0; k < 26; ++k)
            tmp[k] = a.begin()->first[k] * b.begin()->second;
          ret[tmp] = 1;
        }
        return ret;
      }
    }
  }
  return calculate(s.substr(1, n - 2));
}
string solve(string s, string t) {
  s = normalize(s);
  t = normalize(t);
  map<vector<int>, long long> a = calculate(s);
  map<vector<int>, long long> b = calculate(t);
  if (a == b)
    return "yes";
  else
    return "no";
}
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;
  }
}
