#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

ll expr(string& s, int& i);
ll term1(string& s, int& i);
ll term(string& s, int& i);
ll factor(string& s, int& i);
ll number(string& s, int& i);

bool isdigit(char t) {
	return '0' <= t && t <= '9';
}
bool isalf(char t) {
	return 'a' <= t && t <= 'z';
}

ll mod_pow(ll x, int n) {
	ll ret = 1;
	while (n > 0) {
		if (n % 2)ret = ret * x%mod;
		x = x * x%mod; n >>= 1;
	}
	return ret;
}

ll expr(string& s, int& i) {
	ll val = term1(s, i);
	while (i < s.length()) {
		if (s[i] == ' ') {
			i++; continue;
		}
		if (s[i] == '+' || s[i] == '-') {
			char op = s[i];
			i++;
			ll val2 = term1(s, i);
			if (op == '+') {
				val += val2; if (val >= mod)val -= mod;
			}
			else {
				val += mod - val2; while (val >= mod)val -= mod;
			}
		}
		else break;
	}
	//cout << i << " expr " << val << endl;
	return val;
}
ll term1(string& s, int& i) {
	ll val = term(s, i);
	while (i < s.length() && s[i] == ' ')i++;
	if (i >= s.length() || s[i] == '+' || s[i] == '-'||s[i]==')') {
		return val;
	}
	else {
		ll val2 = term1(s, i);
		val = val * val2%mod;
	}
	//cout << i << " term1 " << val << endl;
	return val;
}
ll term(string& s, int& i) {
	ll val = factor(s, i);
	while (i < s.length() && s[i] == ' ')i++;
	if (i<s.length() && s[i] == '^') {
		i++;
		ll val2 = number(s, i);
		val = mod_pow(val, val2);
	}
	//cout << i << " term " << val << endl;
	return val;
}
ll factor(string& s, int& i) {
	while (i < s.length() && s[i] == ' ')i++;
	if (i<s.length() && isdigit(s[i]))return number(s, i);
	i++;
	while (i < s.length() && s[i] == ' ')i++;
	ll ret = expr(s, i);
	i++;
	while (i < s.length() && s[i] == ' ')i++;
	//cout << i << " fact " << ret << endl;
	return ret;
}
ll number(string& s, int& i) {
	while (s[i] == ' ')i++;
	ll ret = s[i++] - '0';
	while (i < s.length() && isdigit(s[i])) {
		ret = ret * 10 + s[i++] - '0';
		ret %= mod;
	}
	//cout << i << " numb " << ret << endl;
	return ret;
}

vector<vector<ll>> gene(int len) {
	random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> u(0, 2147483647);
	vector<vector<ll>> ret(len);
	rep(i, len) {
		ret[i].resize(26);
		rep(j, 26) {
			ret[i][j] = u(mt);
		}
	}
	return ret;
}

ll calc(string s, vector<ll> t) {
	string upd;
	rep(i, s.length()) {
		if (isalf(s[i])) {
			string u = to_string(t[s[i] - 'a']);
			upd.push_back(' ');
			upd = upd + u;
		}
		else if (isdigit(s[i])) {
			int le = i;
			while (i + 1 < s.length() && isdigit(s[i + 1]))i++;
			upd.push_back(' ');
			Rep1(j, le, i)upd.push_back(s[j]);
		}
		else {
			upd.push_back(s[i]);
		}
	}
	int i = 0;
	//cout << s << endl;
	//cout << upd << endl;
	//cout << upd << endl;
	return expr(upd, i);
}

const int sz = 100;
bool solve() {
	string s;
	vector<string> v;
	while (getline(cin, s)) {
		if (s[0] == '.') {
			break;
		}
		v.push_back(s);
	}
	if (v.size() == 0)return false;
	vector<vector<ll>> test = gene(sz);
	vector<vector<ll>> ans(v.size());
	rep(i, v.size()) {
		ans[i].resize(sz);
		rep(j, sz) {
			ans[i][j] = calc(v[i], test[j]);
			//cout << i << " " << ans[i][j] << endl;
		}
	}
	for (int i = 1; i < v.size(); i++) {
		bool f = (ans[i] == ans[0]);
		if (f) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
	cout << "." << endl;
	return true;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	/*string s = "a+b+c";
	string ss = "(a+b)+c";
	vector<ll> c(26, 0); c[0] = 1, c[1] = 2; c[2] = 3;
	cout << calc(s, c) << endl;
	cout << calc(ss, c) << endl;*/

	//cout << fixed << setprecision(10);
	//init();
	while (true) {
		if (!solve())break;
	}
	//stop
		return 0;
}


Measured memory_bytes: 4080