#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

enum OpeType_t
{
    OPE_ADD_VAR,
    OPE_ADD_CON,
    OPE_SUB_VAR,
    OPE_SUB_CON,
    OPE_SET_VAR,
    OPE_SET_CON,
    OPE_IF,
    OPE_HALT
};

int main()
{
    int n;
    cin >> n;

    int m = 0;
    int maxLoop = n;
    vector<OpeType_t> opeType(n);
    vector<vector<int> > arg(n);
    vector<int> varIndex(128, -1);
    vector<int> lineIndex(1001, -1);
    for(int i=0; i<n; ++i){
        int line;
        string opeStr;
        cin >> line >> opeStr;
        lineIndex[line] = i;

        int argNum;
        if(opeStr == "ADD"){
            opeType[i] = OPE_ADD_VAR;
            argNum = 3;
        }
        else if(opeStr == "SUB"){
            opeType[i] = OPE_SUB_VAR;
            argNum = 3;
        }
        else if(opeStr == "SET"){
            opeType[i] = OPE_SET_VAR;
            argNum = 2;
        }
        else if(opeStr == "IF"){
            opeType[i] = OPE_IF;
            argNum = 2;
        }
        else{
            opeType[i] = OPE_HALT;
            argNum = 0;
        }

        arg[i].resize(argNum);
        for(int j=0; j<argNum; ++j){
            string s;
            cin >> s;
            if(isdigit(s[0])){
                arg[i][j] = stoi(s);
                if(opeType[i] != OPE_IF)
                    opeType[i] = (OpeType_t)((int)opeType[i] + 1);
            }
            else{
                if(varIndex[s[0]] == -1){
                    varIndex[s[0]] = m;
                    ++ m;
                    maxLoop *= 16;
                }
                arg[i][j] = varIndex[s[0]];
            }
        }
    }
    for(int i=0; i<n; ++i){
        if(opeType[i] == OPE_IF)
            arg[i][1] = lineIndex[arg[i][1]];
    }

    int curr = 0;
    vector<int> var(m, 0);
    while(--maxLoop >= 0){
        bool isEnd = false;
        vector<int> prevVar = var;

        switch(opeType[curr]){
        case OPE_ADD_VAR:
            var[arg[curr][0]] = var[arg[curr][1]] + var[arg[curr][2]];
            ++ curr;
            break;
        case OPE_ADD_CON:
            var[arg[curr][0]] = var[arg[curr][1]] + arg[curr][2];
            ++ curr;
            break;
        case OPE_SUB_VAR:
            var[arg[curr][0]] = var[arg[curr][1]] - var[arg[curr][2]];
            ++ curr;
            break;
        case OPE_SUB_CON:
            var[arg[curr][0]] = var[arg[curr][1]] - arg[curr][2];
            ++ curr;
            break;
        case OPE_SET_VAR:
            var[arg[curr][0]] = var[arg[curr][1]];
            ++ curr;
            break;
        case OPE_SET_CON:
            var[arg[curr][0]] = arg[curr][1];
            ++ curr;
            break;
        case OPE_IF:
            if(var[arg[curr][0]] == 0)
                ++ curr;
            else
                curr = arg[curr][1];
            break;
        case OPE_HALT:
            isEnd = true;
            break;
        }

        if(!(0 <= curr && curr < n))
            isEnd = true;
        for(int i=0; i<m; ++i){
            if(!(0 <= var[i] && var[i] < 16)){
                var[i] = prevVar[i];
                isEnd = true;
            }
        }
        if(isEnd){
            for(int i=0; i<128; ++i){
                if(varIndex[i] != -1)
                    cout << (char)i << '=' << var[varIndex[i]] << endl;
            }
            return 0;
        }
    }

    cout << "inf" << endl;
    return 0;
}

Measured memory_bytes: 3176