#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1LL<<59)

#define int ll

typedef array<int,27> AI;
typedef vector<AI> EX;
typedef string::const_iterator State;

string normalize(string s){
	string t="";
	rep(i,s.size()){
		if(s[i]!=' ')t+=s[i];
		else if(i+1==s.size()||s[i+1]!=' ') t+=s[i];
	}
	rep(i,t.size()-1)assert(t[i]!=' '||t[i+1]!=' ');
	
	string u="";
	rep(i,t.size()){
		char ch = t[i];
		if(ch!=' '){u+=ch;continue;}
		
		if(!(i-1<0||t[i-1]=='('||t[i-1]=='-'||t[i-1]=='+'||t[i-1]=='^')&&!(i+1>=t.size()||t[i+1]==')'||t[i+1]=='-'||t[i+1]=='+'||t[i+1]=='^'))u+=' ';
	}
	rep(i,u.size())if(u[i]==' ')u[i] = '*';
	
	string ret = "";
	rep(i,u.size()){
		ret+=u[i];
		if(i+1>=u.size())continue;
		if(isdigit(u[i])){
			if(u[i+1]=='('||isalpha(u[i+1]))ret+='*';
		}
		if(isalpha(u[i])){
			if(u[i+1]=='('||isdigit(u[i+1])||isalpha(u[i+1]))ret+='*';
		}
		if(u[i]==')'&&(isalpha(u[i+1])||isdigit(u[i+1])||u[i+1]=='('))ret+='*';
	}
	return ret;
}


EX E(State &beg);


int dig(State &beg){
	assert(isdigit(*beg));
	string res = "";
	while(isdigit(*beg)){
		res+=*beg;
		beg++;
	}
	return  stoll(res);
}


EX P(State &beg){
	if(*beg=='('){
		EX ret;
		beg++;
		ret = E(beg);
		beg++;
		return ret;
	}
	else if(isdigit(*beg)){
		int res = dig(beg);
		AI ret;
		ret[0]=res;
		for(int i=1;i<ret.size();i++)ret[i]=0;
		return EX(1,ret);
	}
	else{
		assert(isalpha(*beg));
		char ch = *beg;
		beg++;
		
		if(*beg=='^'){
			beg++;
			int t = dig(beg);
			AI ret;
			rep(i,ret.size())ret[i]=0;
			ret[ch-'a'+1]=t;
			ret[0]=1;
			
			return EX(1,ret);
		}
		else{
			AI ret;
			rep(i,ret.size())ret[i]=0;
			ret[ch-'a'+1]=1;
			ret[0]=1;
			
			return EX(1,ret);
		}
	}
}


AI mul(AI a,AI b){
	AI ret;
	ret[0] = a[0]*b[0];
	for(int i=1;i<a.size();i++){
		ret[i] = a[i]+b[i];
	}
	return ret;
}


bool isZero(AI a){
	if(a[0]==0)return true;
	else return false;
}


bool isSame(AI a,AI b){
	assert(a[0]!=0&&b[0]!=0);
	for(int i=1;i<a.size();i++){
		if( a[i]!=b[i] )return false;
	}
	return true;
}


EX mulEX(EX a,EX b){
	EX t;
	rep(i,a.size()){
		rep(j,b.size()){
			AI res = mul(a[i],b[j]);
			if(!isZero(res))t.pb(res);
		}
	}
	EX ret;
	ret.pb(t[0]);
	for(int i=1;i<t.size();i++){
		bool f=false;
		rep(j,ret.size()){
			if(isSame(t[i],ret[j])){
				f=true;
				ret[j][0]+=t[i][0];
				if(isZero(ret[j])) ret.erase(ret.begin()+j);
				break;
			}
		}
		if(!f){
			ret.pb(t[i]);
		}
	}
	
	return ret;
}


EX T(State &beg){
	assert(isdigit(*beg)||isalpha(*beg)||*beg=='(');
	vector<EX> t;
	t.pb(P(beg));
	
	while(*beg=='*'){
		beg++;
		t.pb(P(beg));
		
	}
	EX ret = t[0];
	
	for(int i=1;i<t.size();i++){
		ret = mulEX(ret,t[i]);
	}
	return ret;
}


EX removeZero(EX a){
	EX ret;
	rep(i,a.size()){
		if(!isZero(a[i]))ret.pb(a[i]);
	}
	return ret;
}


EX E(State &beg){
	EX ret = removeZero(T(beg));
	
	while(*beg=='+'||*beg=='-'){
		if(*beg=='+'){
			beg++;
			EX t = removeZero(T(beg));
			rep(i,t.size()){
				bool f=false;
				rep(j,ret.size()){
					if(isSame(t[i],ret[j])){
						f=true;
						ret[j][0]+=t[i][0];
						if(isZero(ret[j])) ret.erase(ret.begin()+j);
						break;
					}
				}
				if(!f){
					ret.pb(t[i]);
				}
			}
		}else if(*beg=='-'){
			beg++;
			EX t = removeZero(T(beg));
			rep(i,t.size()){
				bool f=false;
				rep(j,ret.size()){
					if(isSame(t[i],ret[j])){
						f=true;
						ret[j][0]-=t[i][0];
						if(isZero(ret[j])) ret.erase(ret.begin()+j);
						break;
					}
				}
				if(!f){
					t[i][0]*=-1;
					ret.pb(t[i]);
				}
			}
		}
		ret = removeZero(ret);
	}
	return ret;
}


bool isMatch(EX a,EX b){
	sort(all(a));
	sort(all(b));
	if(a==b)return true;
	else return false;
}


signed main(){
	assert(normalize(" (a - b) (0-b+a) - 1a ^ 2 - b ^ 2+ xyz^3xx(a+b)(b+a) ")=="(a-b)*(0-b+a)-1*a^2-b^2+x*y*z^3*x*x*(a+b)*(b+a)");
	while(1){
		vector<string> vs;
		string s;
		while(getline(cin,s)&&s!="."){
			vs.pb(s);
		}
		if(vs.size()==0)break;
		
		rep(i,vs.size()) vs[i] = normalize(vs[i]);
		
		vector<EX> ans;
		rep(i,vs.size()){
			State beg = vs[i].begin();
			EX res = E(beg);
			ans.pb(res);
			rep(i,res.size())assert(!isZero(res[i]));
		}
		
		for(int i=1;i<ans.size();i++){
			if(isMatch(ans[0],ans[i])){
				cout<<"yes"<<endl;
			}
			else cout<<"no"<<endl;
		}
		cout<<"."<<endl;
	}
}