#include<bits/stdc++.h>
using namespace std;
int N;
int s[100];
char t[100][10];
int u[100],v[100],w[100];

int num[1000];

int s2i(string str){
  stringstream ss;
  ss<<str;
  int res;
  ss>>res;
  return res;
}

int change(int x){
  if(0<=x){
    return x;
  }else{
    return num[-x];
  }
}

void setvalue(int x,int y){
  assert( x<0 );
  num[-x]=y;
}

int main(){

  set<char> st;
  map<int,int> lp;  
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&s[i]);
    assert( lp.count(s[i]) == 0 );
    lp[ s[i] ] = i;
    
    scanf("%s",t[i]);
    string a,b,c;
    
    if(t[i][0]=='A'){
      cin>>a>>b>>c;
      if('a'<=a[0]&&a[0]<='z')u[i]=-1*(int)a[0],st.insert(a[0]);
      else assert(0);
      
      if('a'<=b[0]&&b[0]<='z')v[i]=-1*(int)b[0],st.insert(b[0]);
      else v[i]=s2i(b);

      if('a'<=c[0]&&c[0]<='z')w[i]=-1*(int)c[0],st.insert(c[0]);
      else w[i]=s2i(c);

    }else if(t[i][0]=='S'&&t[i][1]=='U'){
      cin>>a>>b>>c;
      if('a'<=a[0]&&a[0]<='z')u[i]=-1*(int)a[0],st.insert(a[0]);
      else assert(0);
      
      if('a'<=b[0]&&b[0]<='z')v[i]=-1*(int)b[0],st.insert(b[0]);
      else v[i]=s2i(b);

      if('a'<=c[0]&&c[0]<='z')w[i]=-1*(int)c[0],st.insert(c[0]);
      else w[i]=s2i(c);

      
    }else if(t[i][0]=='S'&&t[i][1]=='E'){
      cin>>a>>b;
      if('a'<=a[0]&&a[0]<='z')u[i]=-1*(int)a[0],st.insert(a[0]);
      else assert(0);

      if('a'<=b[0]&&b[0]<='z')v[i]=-1*(int)b[0],st.insert(b[0]);
      else v[i]=s2i(b);
      
    }else if(t[i][0]=='I'){
      cin>>a>>b;
      if('a'<=a[0]&&a[0]<='z')u[i]=-1*(int)a[0],st.insert(a[0]);
      else assert(0);

      if('a'<=b[0]&&b[0]<='z')assert(0);
      else v[i]=s2i(b);

      
    }else if(t[i][0]=='H'){
      
    }else assert(0);
  }

  int mx=60000000;
  int p=0,cc=0;
  while(cc < mx){
    
    if(t[p][0]=='A'){
      int value=change(v[p])+change(w[p]);
      if(value<0 || 16<=value)break;
      setvalue(u[p],value);
      p++;
    }else if(t[p][0]=='S'&&t[p][1]=='U'){
      int value=change(v[p])-change(w[p]);
      if(value<0 || 16<=value)break;
      setvalue(u[p],value);
      p++;
    }else if(t[p][0]=='S'&&t[p][1]=='E'){
      int value=change(v[p]);
      if(value<0 || 16<=value)break;
      setvalue(u[p],value);
      p++;
    }else if(t[p][0]=='I'){
      int value=change(u[p]);
      if(value > 0 ){
        int next=change(v[p]);
        if( lp.count( next ) == 0 )break;
        p=lp[next];
      }else{
        p++;
      }


    }else if(t[p][0]=='H'){
      break;
    }else assert(0);

    
    cc++;
    if(p==N)break;
  }
  
  if(cc<mx){
    set<char> :: iterator it;
    for(it=st.begin();it!=st.end();it++){
      int f=*it;
      printf("%c=%d\n", *it, change(-f) );
    }
  }else{
    printf("inf\n");
  }
  
  return 0;
}