#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int64;
 
unordered_map< string, int > ff;
 
void stop()
{
  int ret = 0;
  vector< pair< char, int > > vv;
  for(auto &c : ff) if(isalpha(c.first[0])) vv.emplace_back(c.first[0], c.second);
  sort(begin(vv), end(vv));
  for(auto& c : vv) printf("%c=%d\n", c.first, c.second);
  exit(0);
}
 
 
int main()
{
  int N;
  int convert[1001];
  char buff[64], type[50][5], var1[50][5], var2[50][5], var3[50][5];
  memset(convert, -1, sizeof(convert));
 
  fgets(buff, sizeof(buff), stdin);
  sscanf(buff, "%d", &N);
 
  for(int i = 0; i < N; i++) {
    int line;
    fgets(buff, sizeof(buff), stdin);
    sscanf(buff, "%d %s %s %s %s", &line, type[i], var1[i], var2[i], var3[i]);
    convert[line] = i;
    ff[var1[i]];
    ff[var2[i]];
    ff[var3[i]];
  }
  for(int i = 0; i < 16; i++) ff[to_string(i)] = i;
 
  int i = 0;
  for(int c = 0; c < 30000000; c++) {
    if(type[i][0] == 'H') stop();
    int val;
    bool set = true;
    if(type[i][0] == 'A') {
      val = ff[var2[i]] + ff[var3[i]];
    } else if(type[i][1] == 'U') {
      val = ff[var2[i]] - ff[var3[i]];
    } else if(type[i][1] == 'E') {
      val = ff[var2[i]];
    } else {
      set = false;
    }
 
    if(set && (val < 0 || val >= 16)) stop();
    if(set) ff[var1[i]] = val;
 
    if(type[i][0] == 'I' && ff[var1[i]] != 0) {
      i = convert[stoi(var2[i])];
    } else {
      i++;
    }
 
    if(i < 0 || i >= N) stop();
  }
 
  puts("inf");
}