#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;

string s;
int p;

ll A[200][300];
int idx;

ll bnf();

ll get_num(){

  if(s[p]=='('){
    
    p++;

    ll res=bnf();
    
    p++;

    return res;
  }
  
  if('a'<=s[p]&&s[p]<='z') return A[idx][s[p++]];
  
  ll num=0;
  
  while('0'<=s[p]&&s[p]<='9') num=num*10+s[p]-'0', p++;

  return num;
  
}

ll bnf3(){

  ll res=get_num();
  
  while(p<s.size()){

    if(s[p]=='^'){

      p++;

      ll r=get_num();

      ll tmp=1;

      for(int i=0;i<r;i++) tmp*=res;

      res=tmp;
      
    }else break;
    
  }
  
  return res;
}

ll bnf2(){

  ll res=bnf3();

  while(p<s.size()){

    if(s[p]=='*'){

      p++;

      ll r=bnf3();
      
      res*=r;
      
    }else break;
    
  }
  
  return res;
}

ll bnf(){

  ll res=bnf2();
  
  while(p<s.size()){
    
    if(s[p]=='+'){

      p++;
      
      ll r=bnf2();
      
      res+=r;
      
    }
    else if(s[p]=='-'){

      p++;

      ll 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 T=0;T<200;T++)
    
    for(int i=0;i<300;i++) A[T][i]=rand();
  
  while(1){

    string tmp=s;
    
    getline(cin,s);
    
    if(s==".") break;
    
    change();
    
    ll base[200];

    for(int T=0;T<200;T++){
      idx=T;
      p=0;
      base[T]=bnf();
    }
    
    while(1){
      
      getline(cin,s);
      
      if(s=="."){
	cout<<"."<<endl;
	break;
      }
      
      change();
      
      bool ans=true;
      
      for(int T=0;T<200;T++){
          
	idx=T;  
	p=0;
      
	ll r=bnf();
	
	if(base[T]!=r) ans=false;
	
      }
      
      if(ans) cout<<"yes"<<endl;
      else cout<<"no"<<endl;
      
    }
    
  }
  
  return 0;
}