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>
using namespace std;

int num_id[500];
char num_rev[6];
int num_cnt = 0;
int num[6]={};
string info[52],var[52][3];
int line[52],dest[52],con[52];

int id_cnt[1002]={};
int id_rev[52]={};

int n;

priority_queue<pair<char,int> >pq;

// N,num1,num2,num3,num4,num5
int dp[52][16][16][16][16][16] = {};
int die = 0;

int main(){

  for(int i=0;i<500;i++)num_id[i]=-1;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>line[i];
    id_cnt[line[i]]=1;id_rev[line[i]]=i;
    cin>>info[i];
    if(info[i] == "ADD" || info[i] == "SUB"){
      cin>>var[i][0]>>var[i][1]>>var[i][2];
      if(num_id[var[i][0][0]]==-1){
	num_id[var[i][0][0]] = num_cnt;num_rev[num_cnt]=var[i][0][0];num_cnt++;
      }
      if(num_id[var[i][1][0]]==-1){
	num_id[var[i][1][0]] = num_cnt;num_rev[num_cnt]=var[i][1][0];num_cnt++;
      }
      if('a' <= var[i][2][0] && var[i][2][0] <= 'z'){
	if(num_id[var[i][2][0]]==-1){
	  num_id[var[i][2][0]] = num_cnt;num_rev[num_cnt]=var[i][2][0];num_cnt++;
	}
      }
    }
    if(info[i] == "SET"){
      cin>>var[i][0]>>var[i][1];
      if(num_id[var[i][0][0]]==-1){
	num_id[var[i][0][0]] = num_cnt;num_rev[num_cnt]=var[i][0][0];num_cnt++;
      }
      if('a' <= var[i][1][0] && var[i][1][0] <= 'z'){
	if(num_id[var[i][1][0]]==-1){
	  num_id[var[i][1][0]] = num_cnt;num_rev[num_cnt]=var[i][1][0];num_cnt++;
	}
      }
    }
    if(info[i] == "IF"){
      cin>>var[i][0]>>dest[i];
      if(num_id[var[i][0][0]]==-1){
	num_id[var[i][0][0]] = num_cnt;num_rev[num_cnt]=var[i][0][0];num_cnt++;
      }
    }
  }

  int now_line=0;
  int temp,tt,hoge;
  while(now_line<n){
  
    if(dp[now_line][num[0]][num[1]][num[2]][num[3]][num[4]] == 1){
      die = 1;break;
    }
    dp[now_line][num[0]][num[1]][num[2]][num[3]][num[4]] = 1;
    if(info[now_line] == "ADD"){
      temp = num[num_id[var[now_line][1][0]]];
      tt = 0;
      if('a' <= var[now_line][2][0] && var[now_line][2][0] <= 'z'){
	tt = num[num_id[var[now_line][2][0]]];
      }
      else{
	hoge = 0;
	while('0' <= var[now_line][2][hoge] && var[now_line][2][hoge] <= '9'){
	  tt*=10;tt+=var[now_line][2][hoge] - '0';
	  hoge++;
	}
      }
      temp += tt;
      if(temp<0 || 15<temp)break;
      num[num_id[var[now_line][0][0]]] = temp;
      now_line++;
    }
    else if(info[now_line] == "SUB"){
      temp = num[num_id[var[now_line][1][0]]];
      tt = 0;
      if('a' <= var[now_line][2][0] && var[now_line][2][0] <= 'z'){
	tt = num[num_id[var[now_line][2][0]]];
      }
      else{
	hoge = 0;
	while('0' <= var[now_line][2][hoge] && var[now_line][2][hoge] <= '9'){
	  tt*=10;tt+=var[now_line][2][hoge] - '0';
	  hoge++;
	}
      }
      temp -= tt;
      if(temp<0 || 15<temp)break;
      num[num_id[var[now_line][0][0]]] = temp;
      now_line++;
    }
    else if(info[now_line] == "SET"){
      temp=0;
      if('a' <= var[now_line][1][0] && var[now_line][1][0] <= 'z'){
	temp = num[num_id[var[now_line][1][0]]];
      }
      else{
	hoge = 0;
	while('0' <= var[now_line][1][hoge] && var[now_line][1][hoge] <= '9'){
	  temp*=10;temp+=var[now_line][1][hoge] - '0';
	  hoge++;
	}
      }
      if(temp<0 || 15<temp)break;
      num[num_id[var[now_line][0][0]]] = temp;
      now_line++;
    }
    else if(info[now_line] == "IF"){
      temp = num[num_id[var[now_line][0][0]]];
      if(temp!=0){
	if(!id_cnt[dest[now_line]])break;
	now_line = id_rev[dest[now_line]];
      }
      else{
	now_line++;
      }
    }
    else if(info[now_line] == "HALT")break;
  }

  if(die)cout<<"inf"<<endl;
  else{
    for(int i=0;i<num_cnt;i++){
      pq.push(make_pair(num_rev[i],num[i]));
    }
    int ans[10];char ans_c[10];
    for(int i=num_cnt-1;i>=0;i--){
      pair<char,int>f = pq.top();pq.pop();
      ans_c[i] = f.first;ans[i] = f.second;
    }
    for(int i=0;i<num_cnt;i++){
      cout<<ans_c[i]<<"="<<ans[i]<<endl;
    }
  }

  return(0);
}