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

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
def solve():
	from sys import stdin
	f_i = stdin
	N = int(f_i.readline())
	from string import ascii_lowercase
	next_line = {}
	S = {}
	V = {}
	line = 0
	for i in range(N):
		stmt = f_i.readline().split()
		next_line[line] = stmt[0]
		line = stmt[0]
		op = stmt[1]
		if op == 'ADD' or op == 'SUB':
			(v1, v2, v3) = stmt[2:]
			V[v1] = 0
			V[v2] = 0
			if v3 in ascii_lowercase:
				V[v3] = 0
			else:
				V[v3] = int(v3)
			S[line] = (op, v1, v2, v3)
		elif op == 'SET':
			(v1, v2) = stmt[2:]
			V[v1] = 0
			if v2 in ascii_lowercase:
				V[v2] = 0
			else:
				V[v2] = int(v2)
			S[line] = (op, v1, v2)
		elif op == 'IF':
			(v1, d) = stmt[2:]
			V[v1] = 0
			S[line] = (op, v1, d)
		else:
			S[line] = (op,)
	next_line[line] = None
	v_num = 0
	for k in V:
		if k in ascii_lowercase:
			v_num += 1
	state_limit = len(S) * 16 ** v_num
	nl = next_line[0]
	s = S[nl]
	cnt = 0
	while cnt < state_limit:
		cnt += 1
		op = s[0]
		if op == 'HALT':
			break
		elif op == 'ADD':
			v = V[s[2]] + V[s[3]]
			if v >= 16:
				break
			V[s[1]] = v
		elif op == 'SUB':
			v = V[s[2]] - V[s[3]]
			if v < 0:
				break
			V[s[1]] = v
		elif op == 'SET':
			V[s[1]] = V[s[2]]
		elif V[s[1]]:
			nl = s[2]
			if nl in next_line:
				s = S[nl]
				continue
			else:
				break
		nl = next_line[nl]
		if nl == None:
			break
		s = S[nl]
	if cnt == state_limit:
		print('inf')
	else:
		ans = []
		for (k, v) in V.items():
			if k in ascii_lowercase:
				ans.append('{}={}'.format(k, v))
		ans.sort()
		print('\n'.join(ans))
solve()


from itertools import product

def check():
	n = int(input())
	prog = [input().split() for _ in range(n)]
	v = set()
	for ss in prog:
		for s in ss:
			if 'a' <= s <= 'z':
				v.add(s)
	v = sorted(list(v))
	var_state = [0] * len(v)
	var_to_ind = dict(zip(v, range(len(v))))
	line_to_ind = {}
	for (i, ss) in enumerate(prog):
		line_to_ind[ss[0]] = i

	def fix(p):
		if p[1] == 'ADD':
			if p[4] in var_to_ind:
				return [0, var_to_ind[p[2]], var_to_ind[p[3]], var_to_ind[p[4]]]
			else:
				return [1, var_to_ind[p[2]], var_to_ind[p[3]], int(p[4])]
		if p[1] == 'SUB':
			if p[4] in var_to_ind:
				return [2, var_to_ind[p[2]], var_to_ind[p[3]], var_to_ind[p[4]]]
			else:
				return [3, var_to_ind[p[2]], var_to_ind[p[3]], int(p[4])]
		if p[1] == 'SET':
			if p[3] in var_to_ind:
				return [4, var_to_ind[p[2]], var_to_ind[p[3]]]
			else:
				return [5, var_to_ind[p[2]], int(p[3])]
		if p[1] == 'IF':
			if p[3] in line_to_ind:
				return [6, var_to_ind[p[2]], line_to_ind[p[3]]]
			else:
				return [6, var_to_ind[p[2]], 100]
		if p[1] == 'HALT':
			return [7]
	prog = list(map(fix, prog))
	used = [[False] * n for _ in range(16 ** len(v))]
	xs = [1, 16, 256, 4096, 65536]
	ind = 0
	h = 0
	while True:
		if ind >= n:
			return (True, v, var_state)
		if used[h][ind]:
			return (False, v, var_state)
		used[h][ind] = True
		p = prog[ind]
		ins = p[0]
		if ins == 0:
			(v1, v2, v3) = p[1:]
			temp = var_state[v2] + var_state[v3]
			if not temp < 16:
				return (True, v, var_state)
			h += (temp - var_state[v1]) * xs[v1]
			var_state[v1] = temp
		elif ins == 1:
			(v1, v2) = p[1:3]
			con = p[3]
			temp = var_state[v2] + con
			if not temp < 16:
				return (True, v, var_state)
			h += (temp - var_state[v1]) * xs[v1]
			var_state[v1] = temp
		elif ins == 2:
			(v1, v2, v3) = p[1:]
			temp = var_state[v2] - var_state[v3]
			if not 0 <= temp:
				return (True, v, var_state)
			h += (temp - var_state[v1]) * xs[v1]
			var_state[v1] = temp
		elif ins == 3:
			(v1, v2) = p[1:3]
			con = p[3]
			temp = var_state[v2] - con
			if not 0 <= temp:
				return (True, v, var_state)
			h += (temp - var_state[v1]) * xs[v1]
			var_state[v1] = temp
		elif ins == 4:
			(v1, v2) = p[1:]
			h += (var_state[v2] - var_state[v1]) * xs[v1]
			var_state[v1] = var_state[v2]
		elif ins == 5:
			v1 = p[1]
			con = p[2]
			h += (con - var_state[v1]) * xs[v1]
			var_state[v1] = con
		elif ins == 6:
			v1 = p[1]
			dest = p[2]
			if var_state[v1]:
				ind = dest - 1
		else:
			return (True, v, var_state)
		ind += 1
(flag, v, var_state) = check()
if flag:
	for t in zip(v, var_state):
		print(*t, sep='=')
else:
	print('inf')


n = int(input())
stmts = [input().split() for i in range(n)]
mapper = {}
for (i, stmt) in enumerate(stmts):
	mapper[stmt[0]] = i
vn = {}
for stmt in stmts:
	for ope in stmt[2:]:
		if ope.isalpha() and ope not in vn:
			vn[ope] = len(vn)
vs = [0] * len(vn)

def stmt_add(v1, v2, v3):
	v1 = vn[v1]
	if v3.isdigit():
		v2 = vn[v2]
		const = int(v3)

		def run(pc):
			assert vs[v2] + const < 16
			vs[v1] = vs[v2] + const
			return pc + 1
	else:
		v2 = vn[v2]
		v3 = vn[v3]

		def run(pc):
			assert vs[v2] + vs[v3] < 16
			vs[v1] = vs[v2] + vs[v3]
			return pc + 1
	return run

def stmt_sub(v1, v2, v3):
	v1 = vn[v1]
	if v3.isdigit():
		v2 = vn[v2]
		const = int(v3)

		def run(pc):
			assert 0 <= vs[v2] - const
			vs[v1] = vs[v2] - const
			return pc + 1
	else:
		v2 = vn[v2]
		v3 = vn[v3]

		def run(pc):
			assert 0 <= vs[v2] - vs[v3]
			vs[v1] = vs[v2] - vs[v3]
			return pc + 1
	return run

def stmt_set(v1, v2):
	v1 = vn[v1]
	if v2.isdigit():
		v2 = int(v2)

		def run(pc):
			vs[v1] = v2
			return pc + 1
	else:
		v2 = vn[v2]

		def run(pc):
			vs[v1] = vs[v2]
			return pc + 1
	return run

def stmt_if(v1, dest):
	v1 = vn[v1]

	def run(pc):
		return mapper[dest] if vs[v1] else pc + 1
	return run

def stmt_halt():

	def run(pc):
		return n
	return run
stmt_func = []
for (i, stmt) in enumerate(stmts):
	op = stmt[1]
	if op == 'ADD':
		stmt_func.append(stmt_add(*stmt[2:]))
	elif op == 'SUB':
		stmt_func.append(stmt_sub(*stmt[2:]))
	elif op == 'SET':
		stmt_func.append(stmt_set(*stmt[2:]))
	elif op == 'IF':
		stmt_func.append(stmt_if(*stmt[2:]))
	else:
		stmt_func.append(stmt_halt())
result = 1
pc = 0
cnts = [0] * n
LIM = 16 ** len(vn) + 10
try:
	while 1:
		run = stmt_func[pc]
		cnts[pc] += 1
		if cnts[pc] > LIM:
			result = 0
			break
		pc = run(pc)
except:
	...
if result:
	for k in sorted(vn):
		print('%s=%d' % (k, vs[vn[k]]))
else:
	print('inf')