#include <bits/stdc++.h>
using namespace std;
char in[120];
long long var[30];
char str[210];
int cur;
long long expr();
long long term() {
  if ('0' <= str[cur] && str[cur] <= '9') {
    long long ret = 0;
    while ('0' <= str[cur] && str[cur] <= '9') {
      ret *= 10;
      ret += str[cur++] - '0';
    }
    return ret;
  }
  if (str[cur] == '(') {
    cur++;
    long long ret = expr();
    cur++;
    return ret;
  }
  if ('a' <= str[cur] && str[cur] <= 'z') {
    long long ret = var[str[cur] - 'a'];
    cur++;
    if (str[cur] == '^') {
      cur++;
      int po = str[cur] - '0';
      cur++;
      long long val = 1;
      for (int i = 0; i < po; i++) val *= ret;
      ret = val;
    }
    return ret;
  }
}
long long fact() {
  long long ret = term();
  while (str[cur] == '*' ||
         (str[cur] != '+' && str[cur] != '-' && str[cur] && str[cur] != ')')) {
    if (str[cur] == '*') cur++;
    long long tmp = term();
    ret *= tmp;
  }
  return ret;
}
long long expr() {
  long long ret = fact();
  while (str[cur] == '+' || str[cur] == '-') {
    cur++;
    long long tmp = fact();
    if (str[cur - 1] == '+')
      ret += tmp;
    else
      ret -= tmp;
  }
  return ret;
}
int main() {
  while (1) {
    gets(in);
    if (in[0] == '.') break;
    int at = 0;
    for (int i = 0; in[i]; i++) {
      if (in[i] != ' ') str[at++] = in[i];
    }
    while (1) {
      gets(in);
      if (in[0] == '.') break;
      str[at] = '-';
      str[at + 1] = '(';
      int ind = at + 2;
      for (int i = 0; in[i]; i++) {
        if (in[i] == ' ') {
          if (i && '0' <= in[i - 1] && in[i - 1] <= '9' && '0' <= in[i + 1] &&
              in[i + 1] <= '9') {
            str[ind++] = '*';
          }
          continue;
        }
        str[ind++] = in[i];
      }
      str[ind++] = ')';
      str[ind] = 0;
      bool ok = true;
      for (int i = 0; i < 500; i++) {
        for (int j = 0; j < 26; j++) var[j] = rand() % 30;
        cur = 0;
        if (expr()) {
          ok = false;
          break;
        }
      }
      if (ok)
        printf("yes\n");
      else
        printf("no\n");
    }
    printf(".\n");
  }
}
