#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);
}
    

  

Measured memory_bytes: 163112