#include<stdio.h>
#include<algorithm>
using namespace std;
char in[120];
long double var[30];
char str[210];
int cur;
long double expr();
long double term(){
	if('0'<=str[cur]&&str[cur]<='9'){
		long double ret=0.0L;
		while('0'<=str[cur]&&str[cur]<='9'){
			ret*=10.0L;ret+=(long double)(str[cur++]-'0');
		}
		return ret;
	}
	if(str[cur]=='('){
		cur++;
		long double ret=expr();
		cur++;
		return ret;
	}
	if('a'<=str[cur]&&str[cur]<='z'){
		long double ret=var[str[cur]-'a'];
		cur++;
		if(str[cur]=='^'){
			cur++;
			int po=str[cur]-'0';cur++;
			long double val=1.0L;
			for(int i=0;i<po;i++)val*=ret;
			ret=val;
		}
		return ret;
	}
}
long double fact(){
	long double ret=term();
	while(str[cur]=='*'||(str[cur]!='+'&&str[cur]!='-'&&str[cur]&&str[cur]!=')')){
		if(str[cur]=='*')cur++;
		long double tmp=term();
	//	printf("%Lf * %Lf = %Lf\n",ret,tmp,ret*tmp);
		ret*=tmp;
	}
//	printf("%d %Lf\n",cur,ret);
	return ret;
}
long double expr(){
	long double ret=fact();
	while(str[cur]=='+'||str[cur]=='-'){
		cur++;
		char ch=str[cur-1];
		long double tmp=fact();
		if(ch=='+')ret+=tmp;
		else ret-=tmp;
	}
	return ret;
}
long double ABS(long double a){return max(a,-a);}
int main(){
	while(1){
		gets(in);
		if(in[0]=='.')break;
		int at=0;
		for(int i=0;in[i];i++){
			if(in[i]==' '&&i&&'0'<=str[at-1]&&str[at-1]<='9'&&'0'<=in[i+1]&&in[i+1]<='9'){
				str[at++]='*';
			}
			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'<=str[ind-1]&&str[ind-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]=(long double)(rand()%1000)/200;
				cur=0;
				long double res=expr();
				if(ABS(res)>0.5L){
		//			printf("%s %Lf %Lf\n",str,var[23],res);
					ok=false;break;
				}
			}
			if(ok)printf("yes\n");
			else printf("no\n");
		}
		printf(".\n");
	}
}