#include<bits/stdc++.h>
using namespace std;
typedef __int128  Val;


vector<Val > var;


void skip(string &s,int &p){
  while(p<s.size() && s[p]==' ') p++;
}

Val formula(string &s,int &p);

Val num(string &s,int &p){
  Val res=0.;
  while(p<s.size() && isdigit(s[p])){
    res*=10.;
    res+=s[p]-'0';
    p++;
  }
  skip(s,p);
  return res;
}

Val var_val(string &s,int &p){
  Val res=var[s[p]-'a'];
  p++;
  skip(s,p);
  return res;
}

Val get_val(string &s,int &p){
  if(s[p]=='('){
    p++;
    skip(s,p);
    Val  res=formula(s,p);
    assert(s[p]==')');
    p++;
    skip(s,p);
    return res;
  }
  if(isalpha(s[p])){
    return var_val(s,p);
  }
  if(isdigit(s[p])){
    return num(s,p);
  }
  assert(0);
}

Val term2(string &s,int &p){
  Val res=get_val(s,p);
  if(p<s.size() && s[p]=='^'){
    p++;
    skip(s,p);
    return static_cast<long long int>(pow(res,term2(s,p))+1e9-7);
  }
  return res;
}

Val term1(string& s,int &p){
  Val res=term2(s,p);
  while(p<s.size() && s[p]!=')' && s[p]!='+' && s[p]!='-'){
    skip(s,p);
    assert(isalpha(s[p])||isdigit(s[p])||s[p]=='(');
    Val val=term2(s,p);
    res*=val;
  }
  return res;
}

Val formula(string& s,int &p){
  Val res=term1(s,p);
  while(p<s.size() && s[p]!=')'){
    char op=s[p];
    assert(op=='+' || op=='-');
    p++;
    skip(s,p);
    Val val=term1(s,p);

    if(op=='+') res+=val;
    else res-=val;
  }
  return res;
}

void solve(vector<string> &state){
  random_device rnd;
  var.resize('z'-'a'+1);
  for(int i=1;i<state.size();i++){
    bool isok=true;
    const int TIME=1000;
    for(int j=0;j<TIME;j++){
      int p=0;
      for(int i=0;i<='z'-'a';i++){
	var[i]=rnd()%4;
      }
      Val cor=formula(state[0],p);
      p=0;
      Val ans=formula(state[i],p);
      isok&=(cor==ans);
    }
    cout<<(isok ? "yes" : "no")<<endl;
  }
  return;
}

int main(){
  while(true){
    vector<string> state;
    while(true){
      string buf;
      getline(cin,buf);
      if(buf==".") break;
      state.push_back(buf);
    }
    if(state.size()==0) break;
    solve(state);
  }
  return 0;
}