void init(int m, int n) {
        if (m == 1 && n == 1) {
            closed = true;
            index[0] = 0;
            index[1] = 0;
            return;
        }

        index[0] = 0;
        index[1] = 0;

        max[0] = m;
        max[1] = n;
        count = 1;

        whichIndex = 1;
        step = 1;
        closed = false;

        if (n == 1) {
            whichIndex = 0;
            step = 1;
        }
    }