#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;

int N;
int x[5];
int stmt[50][3], stk[50];
bool done[50][16][16][16][16][16];
map<char, int> hensu;
map<int, int> line;


int main() {
	cin >> N;
	
	vector<pair<int, string> > ord;
	vector<char> c;
	
	REP(i, N) {
		int l;
		scanf("%d ", &l);
		string str;
		getline(cin, str);
		ord.push_back(make_pair(l, str));
		
		stringstream ss(str);
		while (ss) {
			ss >> str;
			if (str.size() == 1 && !isdigit(str[0])) c.push_back(str[0]);
		}
	}
	sort(ALL(c)); c.erase(unique(ALL(c)), c.end());
	REP(i, c.size()) hensu[c[i]] = i;
	REP(i, ord.size()) line[ord[i].fi] = i;
	
	REP(i, ord.size()) {
		stringstream ss(ord[i].se);
		
		string str;
		ss >> str;
		if (str == "ADD") {
			ss >> str; stmt[i][0] = hensu[str[0]];
			ss >> str; stmt[i][1] = hensu[str[0]];
			ss >> str;
			if (str.size() == 1 && !isdigit(str[0])) {
				stk[i] = 0;
				stmt[i][2] = hensu[str[0]];
			}
			else {
				stk[i] = 1;
				stmt[i][2] = atoi(str.c_str());
			}
		}
		else if (str == "SUB") {
			ss >> str; stmt[i][0] = hensu[str[0]];
			ss >> str; stmt[i][1] = hensu[str[0]];
			ss >> str;
			if (str.size() == 1 && !isdigit(str[0])) {
				stk[i] = 2;
				stmt[i][2] = hensu[str[0]];
			}
			else {
				stk[i] = 3;
				stmt[i][2] = atoi(str.c_str());
			}
		}
		else if (str == "SET") {
			ss >> str; stmt[i][0] = hensu[str[0]];
			ss >> str;
			if (str.size() == 1 && !isdigit(str[0])) {
				stk[i] = 4;
				stmt[i][1] = hensu[str[0]];
			}
			else {
				stk[i] = 5;
				stmt[i][1] = atoi(str.c_str());
			}
		}
		else if (str == "IF") {
			ss >> str; stmt[i][0] = hensu[str[0]];
			int dest; ss >> dest;
			stmt[i][1] = dest;
			stk[i] = 6;
		}
		else {
			stk[i] = 7;
		}
		
		if (debug) printf("stk: %d, %d %d %d\n", stk[i], stmt[i][0], stmt[i][1], stmt[i][2]);
	}
	
	bool ng = false;
	int p = 0;
	while (p < N) {
		if (stk[p] == 7) break;
		if (!chmax(done[p][x[0]][x[1]][x[2]][x[3]][x[4]], true)) { ng = true; break; }
		
		if (stk[p] == 6) {
			if (x[stmt[p][0]]) {
				if (!line.count(stmt[p][1])) p = N;
				else p = line[stmt[p][1]];
			}
			else p++;
		}
		else {
			int bef = x[stmt[p][0]];
			switch (stk[p]) {
				case 0: x[stmt[p][0]] = x[stmt[p][1]] + x[stmt[p][2]]; break;
				case 1: x[stmt[p][0]] = x[stmt[p][1]] + stmt[p][2]; break;
				case 2: x[stmt[p][0]] = x[stmt[p][1]] - x[stmt[p][2]]; break;
				case 3: x[stmt[p][0]] = x[stmt[p][1]] - stmt[p][2]; break;
				case 4: x[stmt[p][0]] = x[stmt[p][1]]; break;
				case 5: x[stmt[p][0]] = stmt[p][1]; break;
			}
			
			if (x[stmt[p][0]] < 0 || x[stmt[p][0]] >= 16) {
				x[stmt[p][0]] = bef;
				p = N;
			}
			p++;
		}
	}
	
	
	if (!ng) {
		for (map<char, int>::iterator it = hensu.begin(); it != hensu.end(); ++it) {
			printf("%c=%d\n", it->fi, x[it->se]);
		}
	}
	else puts("inf");
	
	return 0;
}

Measured memory_bytes: 47472