#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef vector<int> vi;	//26
typedef map<vi,int> mvi;
string s;
vi operator+(const vi& x,const vi& y){
	vi z;
	rep(i,26) z.pb(x[i]+y[i]);
	return z;
}
mvi pro(mvi a,mvi b){
	mvi c;
	for(auto p:a) for(auto q:b){
		c[p.fs+q.fs]+=p.sc*q.sc;
	}
	return c;
}
mvi expr(int& it);
int dig(int &it){
	int x=0;
	while(isdigit(s[it])){
		x*=10;
		x+=s[it]-'0';
		it++;
	}
	return x;
}
mvi fac(int &it){
	if(s[it]==' ') it++;
	if(s[it]=='('){
		it++;
		mvi ret=expr(it);
		assert(s[it]==')');
		it++;
		return ret;
	}else if(islower(s[it])){
		int c=s[it]-'a';
		int o=1;
		if(s[it+1]=='^'){
			o=s[it+2]-'0';
			it+=2;
		}
		it++;
		mvi ret;
		vi a(26,0);
		a[c]=o;
		ret[a]=1;
		return ret;
	}else{
		assert(isdigit(s[it]));
		int x=dig(it);
		mvi ret;
		vi a(26,0);
		ret[a]=x;
		return ret;
	}
}
mvi term(int &it){
	mvi ret=fac(it);
	while(it<s.size()&&s[it]!='+'&&s[it]!='-'&&s[it]!=')'){
		mvi a=fac(it);
		ret=pro(ret,a);
	}
	return ret;
}
mvi expr(int& it){
	mvi ret=term(it);
	while(s[it]=='+'||s[it]=='-'){
		if(s[it]=='+'){
			it++;
			mvi a=term(it);
			for(auto p:a) ret[p.fs]+=p.sc;
		}else{
			it++;
			mvi a=term(it);
			for(auto p:a) ret[p.fs]-=p.sc;
		}
	}
	return ret;
}
string igs(string s){
	int i=0;
	while(i<s.size()){
		if(s[i]==' ' && (i==0||!isdigit(s[i-1])||i+1==s.size()||!isdigit(s[i+1])) ) s.erase(i,1);
		else i++;
	}
	return s;
}
bool isame(mvi a,mvi b){
	mvi x,y;
	for(auto p:a) if(p.sc!=0) x[p.fs]=p.sc;
	for(auto p:b) if(p.sc!=0) y[p.fs]=p.sc;
	return x==y;
}
int main(){
	while(true){
		getline(cin,s);
		if(s[0]=='.') break;
		s=igs(s);
		int it=0;
		map<vi,int> ms=expr(it);
		while(true){
			getline(cin,s);
			if(s[0]=='.'){
				puts(".");
				break;
			}
			s=igs(s);
			it=0;
			if(isame(expr(it),ms)) puts("yes");
			else puts("no");
		}
	}
}