public static void push(Integer stackNum, Object val) {
        if (stackNum == 0 && top1 != top3_left + 1) {
            arr[top1] = val;
            top1++;
        } else if (stackNum == 2) {
            if (isLeft && top3_left + 1 != top1) {
                arr[top3_left] = val;
                top3_left--;
            } else if (!isLeft && top3_right != top2) {
                arr[top3_right] = val;
                top3_right++;
            }
            isLeft = !isLeft;
        } else if (stackNum == 1 && top2 != top3_right) {
            top2--;
            arr[top2] = val;
        }
    }