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 <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

enum ORDER{
	ADD,
	SUB,
	SET,
	IF,
	HALT,
};

struct Info{
	ORDER order;
	char var1,var2,var3;
	int con;
};

int current_var[26];
int line[50],rev_line[1001];
Info info[50];
bool check[50][16][16][16][16][16];

char table[50][51];

int main(){

	for(int a = 0; a < 50; a++){
		for(int b = 0; b < 16; b++){
			for(int c = 0; c < 16; c++){
				for(int d = 0; d < 16; d++){
					for(int e = 0; e < 16; e++){
						for(int f = 0; f < 16; f++){
							check[a][b][c][d][e][f] = false;
						}
					}
				}
			}
		}
	}

	for(int i = 0; i <= 1000; i++)rev_line[i] = -1;

	for(int i = 0; i < 26; i++)current_var[i] = -1;

	int N;
	scanf("%d",&N);

	getchar();

	int tmp,index;

	for(int i = 0; i < N; i++){
		fgets(table[i],50,stdin);

		tmp = 0;
		for(index = 0; table[i][index] != ' '; index++){
			tmp = 10*tmp+table[i][index]-'0';
		}
		line[i] = tmp;
		rev_line[tmp] = i;

		index++;
		switch(table[i][index]){
		case 'A': //ADD
			info[i].order = ADD;
			index += 4;
			info[i].var1 = table[i][index];
			current_var[info[i].var1-'a'] = 0;
			index += 2;
			info[i].var2 = table[i][index];
			current_var[info[i].var2-'a'] = 0;
			index += 2;

			if(table[i][index] >= 'a' && table[i][index] <= 'z'){
				info[i].var3 = table[i][index];
				current_var[info[i].var3-'a'] = 0;
			}else{
				tmp = 0;
				for(;table[i][index] >= '0' && table[i][index] <= '9';index++){
					tmp = 10*tmp + table[i][index]-'0';
				}
				info[i].var3 = '@';
				info[i].con = tmp;
			}
			break;
		case 'S':
			if(table[i][index+1] == 'U'){
				info[i].order = SUB;
				index += 4;
				info[i].var1 = table[i][index];
				current_var[info[i].var1-'a'] = 0;
				index += 2;
				info[i].var2 = table[i][index];
				current_var[info[i].var2-'a'] = 0;
				index += 2;

				if(table[i][index] >= 'a' && table[i][index] <= 'z'){
					info[i].var3 = table[i][index];
					current_var[info[i].var3-'a'] = 0;
				}else{
					tmp = 0;
					for(;table[i][index] >= '0' && table[i][index] <= '9';index++){
						tmp = 10*tmp + table[i][index]-'0';
					}
					info[i].var3 = '@';
					info[i].con = tmp;
				}
			}else{
				info[i].order = SET;
				index += 4;
				info[i].var1 = table[i][index];
				current_var[info[i].var1-'a'] = 0;
				index += 2;
				if(table[i][index] >= 'a' && table[i][index] <= 'z'){
					info[i].var2 = table[i][index];
					current_var[info[i].var2-'a'] = 0;
				}else{
					tmp = 0;
					for(;table[i][index] >= '0' && table[i][index] <= '9';index++){
						tmp = 10*tmp + table[i][index]-'0';
					}
					info[i].var2 = '@';
					info[i].con = tmp;
				}
			}
			break;
		case 'I':
			info[i].order = IF;
			index += 3;
			info[i].var1 = table[i][index];
			current_var[info[i].var1-'a'] = 0;
			index += 2;

			tmp = 0;
			for( ;table[i][index] >= '0' && table[i][index] <= '9'; index++){
				tmp = 10*tmp+table[i][index]-'0';
			}
			info[i].con = tmp;
			break;
		case 'H':
			info[i].order = HALT;
			break;
		}
	}

	int array[5];
	int var_num = 0;
	for(int i = 0; i < 26; i++){
		if(current_var[i] == 0){
			array[var_num] = i;
			var_num++;
		}
	}

	bool LOOP_FLG = false,HALT_FLG = false;

	int line = 0;
	int tmp_1,tmp_2;
	int num[5];

	while(true){

		for(int i = 0; i < 5; i++)num[i] = 0;

		for(int i = 0; i < var_num; i++){
			num[i] = current_var[array[i]];
		}

		if(check[line][num[0]][num[1]][num[2]][num[3]][num[4]]){
			LOOP_FLG = true;
			break;
		}else{
			check[line][num[0]][num[1]][num[2]][num[3]][num[4]] = true;
		}

		switch(info[line].order){
		case ADD:
			tmp_1 = current_var[info[line].var2-'a'];

			if(info[line].var3 == '@'){
				tmp_2 = info[line].con;
			}else{
				tmp_2 = current_var[info[line].var3-'a'];
			}

			if(tmp_1+tmp_2 >= 16){
				HALT_FLG = true;
			}else{
				current_var[info[line].var1-'a'] = tmp_1+tmp_2;
			}
			line++;
			break;
		case SUB:
			tmp_1 = current_var[info[line].var2-'a'];

			if(info[line].var3 == '@'){
				tmp_2 = info[line].con;
			}else{
				tmp_2 = current_var[info[line].var3-'a'];
			}

			if(tmp_1-tmp_2 < 0){
				HALT_FLG = true;
			}else{
				current_var[info[line].var1-'a'] = tmp_1-tmp_2;
			}
			line++;
			break;
		case SET:
			if(info[line].var2 == '@'){
				tmp_1 = info[line].con;
			}else{
				tmp_1 = current_var[info[line].var2-'a'];
			}
			current_var[info[line].var1-'a'] = tmp_1;
			line++;
			break;
		case IF:
			if(current_var[info[line].var1-'a'] == 0){
				line++;
			}else{
				if(rev_line[info[line].con] == -1){
					HALT_FLG = true;
				}else{
					line = rev_line[info[line].con];
				}
			}
			break;
		case HALT:
			HALT_FLG = true;
			break;
		}
		if(line == N || HALT_FLG == true)break;
	}


	if(LOOP_FLG){
		printf("inf\n");
	}else{
		for(int i = 0; i < 26; i++){
			if(current_var[i] != -1){
				printf("%c=%d\n",'a'+i,current_var[i]);
			}
		}
	}

	return 0;
}