#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<memory>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000000;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
#define ptr shared_ptr
//class some;
/*class hai{
public:
	int siz;
	ptr<some> num;
	ptr<hai> hi,mg;
	//sizはその要素のサイズを表す
	//numはsizが1の時に入っている要素を表す
};*/
class some{
public:
	char enz;//どの演算を行いますか?
	ptr<some> hi,mg;llint ban;
	bool syu;
	bool ramukan;//ラムダの完結
	some(void){ramukan=false;syu=false;enz='Q';ban=0;}
	//syukuがtrueなら縮約済み!やった!
};
ptr<some> hairead(ptr<some> in,int soe){
	ptr<some> gen=in->hi;
	while(gen->enz=='H'){
		if(soe<gen->ban){gen=gen->hi;}
		else{soe-=gen->ban;gen=gen->mg;}
	}
	return gen;
}
ptr<some> haiwrite(ptr<some> in,int soe,ptr<some> suu){

	ptr<some> ata(new some());
	ptr<some> gen(new some());
	(*ata)=(*in);
	(*gen)=(*(in->hi));
	ata->hi=gen;
	if(gen->enz!='H'){ata->hi=suu;return ata;}
	while(-1){
		ptr<some>iti(new some());
		if(soe<gen->ban){
			if(gen->hi->enz!='H'){gen->hi=suu;return ata;}
			(*iti)=(*(gen->hi));
			gen->hi=iti;
			gen=iti;
		}else{
			if(gen->mg->enz!='H'){gen->mg=suu;return ata;}
			soe-=gen->ban;
			(*iti)=(*(gen->mg));
			gen->mg=iti;
			gen=iti;
		}
	}
};
ptr<some> sai_hai(int soe,ptr<some>suu){
	
	if(soe==1){return suu;}
	ptr<some>ans(new some());
	ans->enz='H';ans->ban=soe/2;
	ans->hi=sai_hai(soe/2,suu);
	ans->mg=sai_hai((soe+1)/2,suu);
	return ans;
}
ptr<some> make_hai(int soe,ptr<some> suu){
	ptr<some>ans(new some());
	ans->enz='h';ans->ban=soe;
	if(soe>0){ans->hi=sai_hai(soe,suu);}
	return ans;
}

ptr<some> unite_hai(ptr<some> v,ptr<some>w){
	if(v->ban==0){return w;}
	if(w->ban==0){return v;}
	ptr<some>ans(new some());
	ptr<some>tgi(new some());
	ans->enz='h';ans->ban=v->ban+w->ban;ans->hi=tgi;
	tgi->enz='H';tgi->ban=v->ban;tgi->hi=v->hi;tgi->mg=w->hi;
	return ans;
}
//let束縛

string str;
int hibas=0;
map<llint,ptr<some>>letnames;
vector<string>atnames;
const llint itmo=2.19e16+13;
llint roll(string in){
	llint ans=0;
	for(auto it:in){ans*=133;ans+=it;ans%=itmo;}
	return ans;
}
bool vach(char c){return ('a'<=c&&c<='z')||('A'<=c&&c<='Z')||(c=='_');}
ptr<some> pasa(void){
	int scopename=0;
	//ラムダのスコープを探している
	do{hibas++;}while(str[hibas]==' ');
	ptr<some>kan(new some());
	while(str[hibas]=='@'){
		//ラムダ
		//kan->enz='@';
		do{hibas++;}while(str[hibas]==' ');
		string itna;
		while(vach(str[hibas])){
			itna.pub(str[hibas]);
			hibas++;
		}
		while(str[hibas]==' '){hibas++;}
		atnames.pub(itna);
		scopename++;
		//kan->hi=ptr<some>(new some());
		//kan=kan->hi;
		//cerr<<"de";
	}
	//cerr<<"de";
	while(str[hibas]!=')'){
		ptr<some> gen;
		if(str[hibas]=='('){gen=pasa();}
		else{
			gen=ptr<some>(new some());
			//ここで大量の場合分け?
			string itna;
			while(str[hibas]!=' '&&str[hibas]!='('&&str[hibas]!=')'){
				itna.pub(str[hibas]);
				hibas++;
			}
			while(str[hibas]==' '){hibas++;}
			//ここで、各条件は絶対に被らない
			if('0'<=itna[0]&&itna[0]<='9'){
				gen->enz='n';gen->ban=0;
				for(auto it:itna){gen->ban*=10;gen->ban+=it-'0';}
			}else if(itna=="+"){gen->enz='+';}
			else if(itna=="-"){gen->enz='-';}
			else if(itna=="*"){gen->enz='*';}
			else if(itna=="/"){gen->enz='/';}
			else if(itna=="%"){gen->enz='%';}
			else if(itna=="max"){gen->enz='o';}
			else if(itna=="min"){gen->enz='c';}
			else if(itna=="<"){gen->enz='<';}
			else if(itna==">"){gen->enz='>';}
			else if(itna=="vec"||itna=="vector"){gen->enz='v';}
			else if(itna=="uni"||itna=="union"){gen->enz='u';}
			else if(itna=="if"){gen->enz='i';}
			else if(itna=="jf"){gen->enz='j';}
			else if(itna=="for"||itna=="while"){gen->enz='f';}
			else if(itna=="[r]"||itna=="r"){gen->enz='r';}
			else if(itna=="[w]"||itna=="w"){gen->enz='w';}
			else if(itna=="{}"){gen->enz='h';gen->ban=0;}
			else {
				bool atta=0;
				for(int i=0;i<atnames.size();i++){
					if(atnames[i]==itna){
						atta=1;
						gen->enz='&';
						gen->ban=atnames.size()-1-i;
					}
				}
				if(!atta){gen->enz='$';gen->ban=roll(itna);}//どこにもないので未使用のletが確定する
			}
			//cerr<<"itna="<<itna;
		}
		
		if(kan->enz=='Q'){(*kan)=(*gen);}
		else{
			//cerr<<"de";
			ptr<some>ata(new some());
			ata->hi=kan;
			ata->mg=gen;
			ata->enz='#';
			kan=ata;
		}
	}
	ptr<some>ans=kan;
	while(scopename--){
		ptr<some>ata(new some());
		ata->enz='@';
		ata->hi=ans;
		ans=ata;
		atnames.pob();
	}
	do{hibas++;}while(str[hibas]==' ');
	return ans;
}
void letkai(ptr<some>in){
	if(in->enz=='#'||in->enz=='@'){
		if(in->hi->enz=='$'){in->hi=letnames[in->hi->ban];}else{letkai(in->hi);}
	}
	if(in->enz=='#'){
		if(in->mg->enz=='$'){in->mg=letnames[in->mg->ban];}else{letkai(in->mg);}
	}
}
int tabu=0;
void TS(void){for(int i=0;i<tabu;i++){cout<<"    ";}}
void syutu(const ptr<some> in){
	cout<<"{\n";				//}
	tabu++;
	if(in->enz=='@'){//らむだ
		TS();cout<<"enz:@\n";
		//TS();cout<<"arg :"<<in->ban<<endl;
		TS();cout<<"arg:";syutu(in->hi);
	}
	else if(in->enz=='#'){//えんざん
		TS();cout<<"enz:#\n";
		TS();cout<<"arg :";syutu(in->hi);
		TS();cout<<"body:";syutu(in->mg);
	}
	else if(in->enz=='&'){//即値
		TS();cout<<"enz:&\n";
		TS();cout<<"arg :"<<in->ban<<endl;
	}
	else if(in->enz=='n'){TS();cout<<"nut="<<in->ban<<endl;}
	else{TS();cout<<"enz="<<in->enz<<endl;}
	tabu--;
	TS();cout<<"}\n";				//{
}
bool isoy(ptr<some>tai){return (tai!=nullptr&&(!tai->syu)&&(tai->enz=='#'||tai->enz=='@'));}
bool daishi(ptr<some>&tai,int num,ptr<some>&xca){
	//numばんピッタリに代入
	//num未満ならそのまま
	//num超過なら番号をへらす
	if(tai->ramukan){return 0;}
	bool hen=0;
	ptr<some>moto=tai;
	ptr<some> iti(new some());(*iti)=(*tai);tai=iti;tai->syu=0;
	if(tai->enz=='&'&&tai->ban==num){tai=xca;hen=1;}
	else if(tai->enz=='&'&&tai->ban>num){tai->ban--;hen=1;}
	else if(tai->enz=='@'){hen|=daishi(tai->hi,num+1,xca);}
	else if(tai->enz=='#'){hen|=daishi(tai->hi,num,xca);hen|=daishi(tai->mg,num,xca);}
	if(hen){tai->syu=0;}else{tai=moto;}
	return hen;
}

//dainyu(0,0,...)
void WA_RE(int in=-1333){cerr<<"RE"<<in;exit(0);}
void keisan(ptr<some>in){
	if(in==nullptr||in->syu||in->enz!='#'){return;}
	//cerr<<"de "<<in->enz<<endl;
	if(isoy(in->hi)){keisan(in->hi);}
	if(in->hi->enz=='@'){
		//cerr<<"ramu";
		ptr<some> xca=in->mg;
		ptr<some> tai=in->hi->hi;
		daishi(tai,0,xca);
		(*in)=(*tai);
		keisan(in);
		return;
	}
	if(in->hi->enz=='1'){
		if(isoy(in->mg)){keisan(in->mg);}
		in->enz='3';return;
	}
	else if(in->hi->enz=='2'){in->syu=1;in->enz='4';return;}
	else if(in->hi->enz=='3'){(*in)=(*(in->hi->mg));return;}
	else if(in->hi->enz=='4'){
		if(isoy(in->mg)){keisan(in->mg);}
		(*in)=(*(in->mg));return;
	}else if(isoy(in->mg)){keisan(in->mg);}
	char hiz=in->hi->enz,mgz=in->mg->enz;
	//cerr<<"himg="<<hiz<<mgz<<endl;
	
	if(hiz=='#'||hiz=='@'||hiz=='&'){in->syu=1;return;}
	if(mgz=='n'){
		bool yatta=1;
		//if(in->hi->enz=='*'&&in->mg->ban==2){cerr<<"hyo";}
		switch(hiz){
			case '+':in->enz='P';in->ban =in->mg->ban;break;
			case 'P':in->enz='n';in->ban =in->hi->ban+in->mg->ban;break;
			case '-':in->enz='M';in->ban =in->mg->ban;break;
			case 'M':in->enz='n';in->ban =in->hi->ban-in->mg->ban;break;
			case '*':in->enz='T';in->ban =in->mg->ban;break;
			case 'T':in->enz='n';in->ban =in->hi->ban*in->mg->ban;break;
			case '/':in->enz='D';in->ban =in->mg->ban;break;
			case 'D':in->enz='n';in->ban =in->hi->ban/in->mg->ban;break;
			case '%':in->enz='A';in->ban =in->mg->ban;break;
			case 'A':in->enz='n';in->ban =in->hi->ban%in->mg->ban;break;
			case 'o':in->enz='O';in->ban =in->mg->ban;break;
			case 'O':in->enz='n';in->ban =max(in->hi->ban,in->mg->ban);break;
			case 'c':in->enz='C';in->ban =in->mg->ban;break;
			case 'C':in->enz='n';in->ban =min(in->hi->ban,in->mg->ban);break;
			case '<':in->enz='S';in->ban =in->mg->ban;break;
			case 'S':in->enz='n';in->ban=((in->hi->ban < in->mg->ban)?1:0);break;
			case '>':in->enz='B';in->ban =in->mg->ban;break;
			case 'B':in->enz='n';in->ban=((in->hi->ban > in->mg->ban)?1:0);break;
			default:yatta=0;
		}
		if(yatta){
			//cerr<<"ya";
			in->hi=nullptr;in->mg=nullptr;in->syu=1;return;
		}
	}
	if(in->enz!='#'){in->hi=nullptr;in->mg=nullptr;}//計算を行ったので
	if(hiz=='v'&&mgz=='n'){in->enz='V';in->ban=in->mg->ban;}
	if(hiz=='V'){(*in)=(*make_hai(in->hi->ban,in->mg));}
	if(hiz=='u'&&mgz=='h'){in->enz='U';in->hi=in->mg;}
	if(hiz=='U'&&mgz=='h'){(*in)=(*unite_hai(in->hi->hi,in->mg));}
	if(hiz=='h'){
		
		ptr<some>ata(new some());
		ata->ban=1;ata->enz='h';ata->hi=in->mg;
		(*in)=*unite_hai(in->hi,ata);
		
	}
	if(hiz=='r'&&mgz=='h'){in->enz='R';in->hi=in->mg;}
	if(hiz=='R'&&mgz=='n'){(*in)=(*hairead(in->hi->hi,in->mg->ban));}
	if(hiz=='w'&&mgz=='h'){in->enz='W';in->hi=in->mg;}
	if(hiz=='W'&&mgz=='n'){in->enz='=';in->hi=in->hi->hi;in->ban=in->mg->ban;}
	if(hiz=='='){(*in)=(*haiwrite(in->hi->hi,in->hi->ban,in->mg));}
	if(hiz=='i'&&mgz=='n'){in->enz=((in->mg->ban)?'1':'2');}
	if(hiz=='j'&&mgz=='n'){in->enz=((in->mg->ban<0)?'1':'2');}
	in->syu=1;return;
}
#include <sstream>
int main(void){
	/*
		なんかできるようにした
		関数型!!
	*/
	//3 5 7->105
	//3 3 3 5->135
	//3 5 11->165
	//3 5 13->195
	//3 3 3 7->189
	vector<string> codelines={
		"winn n",
		"let a ( + ( if ( < n 105 ) 0 ( / ( - n 75 ) 30)) ( > n 188 ) )",
		"woutn a",
	};
	
	for(auto code:codelines){
		std::istringstream stm(code);
		string mei;stm>>mei;
		if(mei=="winn"){
			string na;stm>>na;
			llint kaz;cin>>kaz;
			llint rollname=roll(na);
			ptr<some> soku(new some());
			soku->enz='n';
			soku->ban=kaz;
			letnames[rollname]=soku;
		}
		if(mei=="winh"){
			string na;stm>>na;//名前
			string enu;stm>>enu;
			for(auto it:letnames){letkai(it.sec);}
			ptr<some>terget=letnames[roll(enu)];
			keisan(terget);
			llint size=0;
			if(terget->enz=='n'){size=terget->ban;}
			else{cout<<"era-"<<endl;}
			//ここで入力量を決める
			ptr<some> zro(new some());zro->enz='n';zro->ban=0;
			ptr<some> haso(make_hai(size,zro));
			for(int i=0;i<size;i++){
				ptr<some> soku(new some());
				soku->enz='n';cin>>soku->ban;
				haso=haiwrite(haso,i,soku);
			}
			letnames[roll(na)]=haso;
		}
		if(mei=="wins"){
			string na;stm>>na;//名前
			string nyu;cin>>nyu;
			int size=nyu.size();
			ptr<some> zro(new some());zro->enz='n';zro->ban=0;
			ptr<some> haso(make_hai(size,zro));
			for(int i=0;i<size;i++){
				ptr<some> soku(new some());
				soku->enz='n';soku->ban=nyu[i];
				haso=haiwrite(haso,i,soku);
			}
			letnames[roll(na)]=haso;
		}
		if(mei=="let"){
			string na;stm>>na;
			getline(stm,str);
			hibas=0;while(str[hibas]==' '){hibas++;}
			if(letnames.count(roll(na))){cout<<"namaenosyoutotu"<<endl;}
			letnames[roll(na)]=pasa();
			letnames[roll(na)]->ramukan=1;
			//syutu(letnames[rollname]);
		}
		if(mei=="woutn"){
			string na;stm>>na;
			//let名前解決する
			for(auto it:letnames){letkai(it.sec);}
			ptr<some>terget=letnames[roll(na)];
			keisan(terget);
			if(terget->enz=='n'){cout<<terget->ban<<endl;}
			else{cout<<"era-"<<endl;}
		}
		if(mei=="wouth"){
			string na;stm>>na;
			for(auto it:letnames){letkai(it.sec);}
			ptr<some>terget=letnames[roll(na)];
			keisan(terget);
			if(terget->enz=='h'){
				cerr<<"a";
				for(int i=0;i<terget->ban;i++){cout<<hairead(terget,i)->ban<<endl;}
			}else{cerr<<"ela-"<<terget->enz<<endl;}
		}
		if(mei=="wouts"){
			string na;stm>>na;
			for(auto it:letnames){letkai(it.sec);}
			ptr<some>terget=letnames[roll(na)];
			keisan(terget);
			if(terget->enz=='h'){
				for(int i=0;i<terget->ban;i++){cout<<(char)(hairead(terget,i)->ban);}
				cout<<endl;
			}else{cerr<<"ela-"<<terget->enz<<endl;}
		}
		if(mei=="end"){return 0;}
	}
	return 0;
}


Measured memory_bytes: 256