#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <bitset>

#define MAX_VALUE (1000 * 16 * 16 * 16 * 16 * 16)


enum cmd_t {
	CMD_ADD,
	CMD_SUB,
	CMD_SET,
	CMD_IF,
	CMD_HALT
};


struct command {
	cmd_t type;
	int var1;
	int var2;
	int var3;
	int opt;
};


struct vm_stat {
	int pc;
	int env[5];

	vm_stat(void) {
		pc = 0;
		env[0] = 0;
		env[1] = 0;
		env[2] = 0;
		env[3] = 0;
		env[4] = 0;
	}

	size_t encode(void) {
		int code = pc;
		code = code * 16 + env[0];
		code = code * 16 + env[1];
		code = code * 16 + env[2];
		code = code * 16 + env[3];
		code = code * 16 + env[4];
		return code;
	}
};


static std::bitset<MAX_VALUE> stats;
static command plist[50];
static int n;
static int lines[1001];

int main(int argc, char* argv[]) {
	int atom['z' - 'a' + 1];
	int atom_n = 0;
	for (int i = 'a'; i <= 'z'; ++i) {
		atom[i - 'a'] = -1;
	}	
	for (int i = 0; i <= 1000; ++i) {
		lines[i] = -1;
	}

	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		char s[16];
		int d;

		scanf("%d", &d);
		lines[d] = i;
		scanf(" %s", s);
		if (strcmp(s, "ADD") == 0) {
			plist[i].type = CMD_ADD;
			scanf(" %s", s);
			if (atom[*s - 'a'] == -1) {
				atom[*s - 'a'] = atom_n++;
			}
			plist[i].var1 = atom[*s - 'a'];
			scanf(" %s", s);
			if (atom[*s - 'a'] == -1) {
				atom[*s - 'a'] = atom_n++;
			}
			plist[i].var2 = atom[*s - 'a'];
			scanf(" %s", s);
			if (isdigit(*s)) {
				plist[i].var3 = -1;
				plist[i].opt = atoi(s);
			}
			else {
				if (atom[*s - 'a'] == -1) {
					atom[*s - 'a'] = atom_n++;
				}
				plist[i].var3 = atom[*s - 'a'];
			}
		}
		else if (strcmp(s, "SUB") == 0) {
			plist[i].type = CMD_SUB;
			scanf(" %s", s);
			if (atom[*s - 'a'] == -1) {
				atom[*s - 'a'] = atom_n++;
			}
			plist[i].var1 = atom[*s - 'a'];
			scanf(" %s", s);
			if (atom[*s - 'a'] == -1) {
				atom[*s - 'a'] = atom_n++;
			}
			plist[i].var2 = atom[*s - 'a'];
			scanf(" %s", s);
			if (isdigit(*s)) {
				plist[i].var3 = -1;
				plist[i].opt = atoi(s);
			}
			else {
				if (atom[*s - 'a'] == -1) {
					atom[*s - 'a'] = atom_n++;
				}
				plist[i].var3 = atom[*s - 'a'];
			}
		}
		else if (strcmp(s, "SET") == 0) {
			plist[i].type = CMD_SET;
			scanf(" %s", s);
			if (atom[*s - 'a'] == -1) {
				atom[*s - 'a'] = atom_n++;
			}
			plist[i].var1 = atom[*s - 'a'];
			scanf(" %s", s);
			if (isdigit(*s)) {
				plist[i].var2 = -1;
				plist[i].opt = atoi(s);
			}
			else {
				if (atom[*s - 'a'] == -1) {
					atom[*s - 'a'] = atom_n++;
				}
				plist[i].var2 = atom[*s - 'a'];
			}
		}
		else if (strcmp(s, "IF") == 0) {
			plist[i].type = CMD_IF;
			scanf(" %s", s);
			if (atom[*s - 'a'] == -1) {
				atom[*s - 'a'] = atom_n++;
			}
			plist[i].var1 = atom[*s - 'a'];
			scanf(" %d", &d);
			plist[i].opt = d;
		}
		else {
			plist[i].type = CMD_HALT;
		}
	}

	vm_stat stat;
	bool halted = true;
	stats.set(stat.encode());
	for (;;) {
		const command c = plist[stat.pc++];

		if (c.type == CMD_ADD) {
			const int rvalue = stat.env[c.var2] + (c.var3 < 0 ? c.opt : stat.env[c.var3]);
			if (rvalue < 0 || 16 <= rvalue) {
				break;
			}
			stat.env[c.var1] = rvalue;
		}
		else if (c.type == CMD_SUB) {
			const int rvalue = stat.env[c.var2] - (c.var3 < 0 ? c.opt : stat.env[c.var3]);
			if (rvalue < 0 || 16 <= rvalue) {
				break;
			}
			stat.env[c.var1] = rvalue;
		}
		else if (c.type == CMD_SET) {
			if (c.var2 < 0) {
				stat.env[c.var1] = c.opt;
			}
			else {
				stat.env[c.var1] = stat.env[c.var2];
			}
		}
		else if (c.type == CMD_IF) {
			if (stat.env[c.var1]) {
				if (lines[c.opt] == -1) {
					break;
				}
				else {
					stat.pc = lines[c.opt];
				}
			}
		}
		else {
			break;
		}

		if (stats.test(stat.encode())) {
			halted = false;
			break;
		}
		if (stat.pc >= n) {
			break;
		}
		stats.set(stat.encode());
	}

	if (halted) {
		for (int i = 'a'; i <= 'z'; ++i) {
			if (atom[i - 'a'] >= 0) {
				printf("%c=%d\n", i, stat.env[atom[i - 'a']]);
			}
		}
	}
	else {
		puts("inf");
	}

	return EXIT_SUCCESS;
}



Measured memory_bytes: 130760