#include <bits/stdc++.h>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
const int mod = 1000000007;

struct Mod {
  int num;
  Mod () : num(0) {;}
  Mod (int n) : num(n) {;}
  operator int() { return num; }
};

Mod operator+(Mod a, Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator-(Mod a, Mod b) { return Mod((mod + a.num - b.num) % mod); }
Mod operator*(Mod a, Mod b) { return Mod(((long long)a.num * b.num) % mod); }
Mod operator+=(Mod &a, Mod b) { return a = a + b; }
Mod operator-=(Mod &a, Mod b) { return a = a - b; }
Mod operator^(Mod a, int n) {
  if (n == 0) return Mod(1);
  Mod res = (a * a) ^ (n / 2);
  if (n % 2) res = res * a;
  return res;
}

pair<Mod, int> expr(const string &s, int i);
pair<Mod, int> num(const string &s, int i) {
  Mod v;
  while('0' <= s[i] && s[i] <= '9') {
    v = v * Mod(10);
    v += Mod(s[i] - '0');
    ++i;
  }
  while(i < s.size() && s[i] == ' ') ++i;
  return make_pair(v, i);
}

pair<Mod, int> factor(const string &s, int i) {
  //cerr << "factor: " << i << ' ';
  Mod val;
  if (s[i] == '(') {
    ++i;
    while(s[i] == ' ') ++i;
    tie(val, i) = expr(s, i);
    assert(s[i] == ')');
    ++i;
    while(i < s.size() && s[i]==' ') ++i;
  } else {
    tie(val, i) = num(s, i);
  }
  if (i < s.size() && s[i] == '^') {
    ++i;
    while(s[i] == ' ') ++i;
    Mod index;
    tie(index, i) = num(s, i);
    val = val ^ index;
  }
  return make_pair(val, i);
}

pair<Mod, int> term(const string &s, int i) {
  //cerr << "term: " << i << ' ';
  Mod val;
  tie(val, i) = factor(s, i);
  while(i < s.size() && !(s[i] == '+' || s[i] == '-' || s[i] == ')')) {
    while(s[i] == ' ') ++i;
    auto p = factor(s, i);
    val = val * p.first;
    i = p.second;
  }
  return make_pair(val, i);
}

pair<Mod, int> expr(const string &s, int i) {
  //cerr << "expr: " << i << ' ';
  Mod val;
  tie(val, i) = term(s, i);
  while(i < s.size() && (s[i] == '+' || s[i] == '-')) {
    char op = s[i];
    ++i;
    while(s[i] == ' ') ++i;
    auto p = term(s, i);
    if (op == '+') val += p.first;
    else val -= p.first;
    i = p.second;
  }
  return make_pair(val, i);
}

int main() {
  random_device rd;
  mt19937 mt(rd());
  while(1){
    vector<string> lines;
    while(1){
      string line;
      getline(cin,line);
      if(line[0] == '.') break;
      lines.push_back(line);
    }
    if(lines.empty()) break;
    vector<char> vals;
    for (auto line:lines)
      for (auto c : line)
        if ('a' <= c && c <= 'z')
          vals.push_back(c);
    sort(begin(vals),end(vals));
    vals.erase(unique(begin(vals),end(vals)),end(vals));
    vector<Mod> rnums;
    for (char c:vals) rnums.emplace_back(mt()%mod);
    vector<Mod> res;
    for (auto line:lines) {
      string rep;
      for (char c:line) {
        if ('a' <= c && c <= 'z') {
          int index = lower_bound(begin(vals),end(vals),c)-begin(vals);
          rep += ' ' + to_string(rnums[index]) + ' ';
        } else {
          rep += c;
        }
      }
      //cout<<rep<<endl;
      int ofs = 0;
      while(rep[ofs] == ' ') ++ofs;
      res.push_back(expr(rep, ofs).first);
    }
    REP(i,res.size()) {
      if (!i) continue;
      //cout<<res[i]<<' '<<res[0]<<endl;
      if (res[i] == res[0]) cout << "yes" << endl;
      else cout << "no" << endl;
    }
    cout<<"."<<endl;
  }
  return 0;
}

Measured memory_bytes: 1392