Problem: Have you ever had an infinite loop when you ran a hard-working program? It would be convenient to be able to determine in advance whether a program will stop executing without having to execute it.

Unfortunately, it is not possible to make such a decision for any program in the programming language you normally use. However, if you have a programming language that is much less computationally powerful, you may be able to write a program that determines if a program written in that language will stop.

Consider a programming language called TinyPower. Programs in this language are line sequences. On each line of the program, write the line number at the beginning and one sentence after it. The types of sentences that can be written in this language are as follows.

Sentence type | Behavior
--- | ---
ADD var1 var2 var3 | Assign the result of adding the value of variable var2 and the value of var3 to variable var1
ADD var1 var2 con | Assign the result of adding the value of the variable var2 and the constant con to the variable var1
SUB var1 var2 var3 | Assign the result of subtracting the value of var3 from the value of variable var2 to variable var1
SUB var1 var2 con | Substitute the result of subtracting the constant con from the value of the variable var2 into the variable var1
SET var1 var2 | Assign the value of variable var2 to variable var1
SET var1 con | Assign the constant con to the variable var1
IF var1 dest | Jump to line number dest only if the value of variable var1 is non-zero
HALT | Stop the program



Line numbers are positive integers, and the same line number will never appear more than once in the program. Variables are represented by a single lowercase letter, and constants and variable values ​​are integers. No variable declaration is required, the initial value of the variable is 0.

Program execution starts with the first statement, and the statements are executed in the order in which they are lined up. However, as written in the table above, if the value of the variable in the IF statement is not 0, jump to the line specified by the line number written after the variable and start from the statement written in that line. Continue running. The program will stop when:

* When the HALT statement is executed.
* When trying to assign a negative integer or an integer greater than or equal to 16 to a variable (the value of the variable is not updated).
* When trying to jump to a line number that does not appear in the program.
* When you do not jump to any line from the last statement of the program.



Create a program that determines if a TinyPower program, given it, will stop.



Input

The input is given in the following format.


N
stmt1
stmt2
::
stmtN


The number of lines N (1 ≤ N ≤ 50) of the program is given on the first line. The following N lines are given the statement stmti of the TinyPower program. stmti is given in one of the following formats:


line ADD var1 var2 var3


Or


line ADD var1 var2 con


Or


line SUB var1 var2 var3


Or


line SUB var1 var2 con


Or


line SET var1 var2


Or


line SET var1 con


Or


line IF var1 dest


Or


line HALT


line, dest (1 ≤ line, dest ≤ 1000) is the line number, varj (one lowercase letter) is the variable, and con (0 ≤ con ≤ 15) is the constant. The delimiter in stmti is one blank character. It is assumed that one or more variables always appear in the program, and only five different variable names appear.

Output

When the program stops, the results of the variables appearing in the program are output in the lexicographic order of the variable names, separated by line breaks, and when it does not stop, "inf" is output. The result of the variable is output by separating the variable name and the value of the variable with "=".

Examples

Input

6
10 SET c 1
20 SET i 5
100 ADD s s i
110 SUB i i c
120 IF i 100
200 HALT


Output

c=1
i=0
s=15


Input

3
10 SET c 1
120 IF c 10
20 HALT


Output

inf


Input

3
111 SET c 1
12 SUB c c 2
777 SET a 4


Output

a=0
c=1

Solution (in CPP):

Solution:
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

struct sentence {
	int type;
	int a;
	int b;
	int c;
};

map<int, int>line_mp;
map<string, int>name_mp;
bool memo[51][(1 << 20)];
int getid(vector<int>&v) {
	int sum = 0;
	for (int i = 0; i < v.size(); ++i) {
		sum *= 16;
		sum+= v[i];
	}
	assert(sum < (1 << 20));
	return sum;
}
int getnum(const string name_st) {
	static int k = 0;
	if (name_mp.find(name_st) == name_mp.end()) {
		name_mp[name_st] = k++;
	}
	return name_mp[name_st];
}
int ansl;
vector<int>ansv;
void solve(const vector<sentence>&sents,int line, vector<int>&v) {
	
	if (memo[line][getid(v)] == 1) {
		ansl = -3;
		throw(false);
	}
	else {

		memo[line][getid(v)] = 1;
		auto sent(sents[line]);
		int type = sent.type;
		int calc;
		int nextline = -1;
		if (type <= 5) {
			switch (type) {
			case 0:
				calc = v[sent.b] + v[sent.c];
				break;
			case 1:
				calc = v[sent.b] + sent.c;
				break;
			case 2:
				calc = v[sent.b] - v[sent.c];
				break;
			case 3:
				calc = v[sent.b] - sent.c;
				break;

			case 4:
				calc = v[sent.b];
				break;
			case 5:
				calc = sent.b;
				break;
			}
			if (calc < 0 || calc >= 16) {
				ansl = line;
				ansv = v;
				throw(false);
			}
			else {
				v[sent.a] = calc;
			}
			nextline = line + 1;
		}
		else {
			switch (type) {
			case 6:
				if (v[sent.a] == 0) {
					nextline = line + 1;
				}
				else {
					nextline = sent.b;
				}
				break;
			case 7:

				ansl = line;
				ansv = v;
				throw(false);
				break;
			}
		}

		
	
		if (nextline == -1||nextline>=sents.size()) {
			ansl = line;
			ansv = v;
			throw(false);
		}

		solve(sents, nextline, v);
	}

	
	
}
int main() {
	for (int i = 0; i < 51; ++i) {
		for (int j = 0; j < (1 << 20); ++j) {
			memo[i][j] =false;
		}
	}
	int N; cin >> N;
	vector <sentence>aas;
	{
		for (int i = 0; i < N; ++i) {
			int l; cin >> l;
			line_mp[l] = i;
			string st; cin >> st;
			if (st == "ADD" || st == "SUB") {
				string a, b, c; cin >> a >> b >> c;
				if (isdigit(c[0])) {
					int anum(getnum(a));
					int bnum(getnum(b));
					aas.push_back(sentence{ (st == "SUB") * 2 + 1,anum,bnum,stoi(c) });
				}
				else {
					int anum(getnum(a));
					int bnum(getnum(b));
					int cnum(getnum(c));
					aas.push_back(sentence{ (st == "SUB") * 2,anum,bnum,cnum });
				}
			}
			else if (st == "SET") {
				string a, b; cin >> a >> b;
				if (isdigit(b[0])) {
					int anum(getnum(a));
					aas.push_back(sentence{ 5,anum,stoi(b),-1 });
				}
				else {
					int anum(getnum(a));
					int bnum(getnum(b));
					aas.push_back(sentence{ 4,anum,bnum,-1 });
				}
			}
			else if (st == "IF") {
				string a; int bnum; cin >> a >> bnum;
				int anum(getnum(a));
				aas.push_back(sentence{ 6,anum,bnum,-1 });

			}
			else {
				assert(st == "HALT");
				aas.push_back(sentence{ 7,-1,-1,-1 });
			}
		}
		for (auto& a : aas) {
			if (a.type == 6) {
				if (line_mp.find(a.b) == line_mp.end()) {
					a.b = -1;
				}
				else {
					a.b = line_mp[a.b];

				}
			}
		}
		
	}
	try {
		vector<int>v(5,0);
		solve(aas, 0, v);
	}
	catch (...) {
		if (ansl == -3)cout << "inf" << endl;
		else {
			vector<pair<string, int>>vars;
			for (auto nm:name_mp) {
				vars.push_back(make_pair(nm.first, ansv[nm.second]));

			}
			sort(vars.begin(),vars.end());
			for(auto var:vars){
				cout << var.first << "=" << var.second << endl;
			}
		}
	}
	
	return 0;
}