def explode(num, item, idx):
    left = item[0]
    right = item[1]
    num[idx[0]][idx[1]][idx[2]][idx[3]] = 0
    for (index, indexValue) in enumerate(idx[::(- 1)]):
        if (indexValue != 0):
            idxLeft = idx[:(4 - index)]
            idxLeft[(- 1)] = 0
            while (type(getValueAtIndex(num, idxLeft)) == list):
                idxLeft.append(1)
            num = changeValueAtIndex(num, idxLeft, left)
            break
    for (index, indexValue) in enumerate(idx[::(- 1)]):
        if (indexValue != 1):
            idxRight = idx[:(4 - index)]
            idxRight[(- 1)] = 1
            while (type(getValueAtIndex(num, idxRight)) == list):
                idxRight.append(0)
            num = changeValueAtIndex(num, idxRight, right)
            break
    return num
def explode(num, item, idx):
    left = item[0]
    right = item[1]
    num[idx[0]][idx[1]][idx[2]][idx[3]] = 0
    for (index, indexValue) in enumerate(idx[::(- 1)]):
        if (indexValue != 0):
            idxLeft = idx[:(4 - index)]
            idxLeft[(- 1)] = 0
            while (type(getValueAtIndex(num, idxLeft)) == list):
                idxLeft.append(1)
            num = changeValueAtIndex(num, idxLeft, left)
            break
    for (index, indexValue) in enumerate(idx[::(- 1)]):
        if (indexValue != 1):
            idxRight = idx[:(4 - index)]
            idxRight[(- 1)] = 1
            while (type(getValueAtIndex(num, idxRight)) == list):
                idxRight.append(0)
            num = changeValueAtIndex(num, idxRight, right)
            break
    return num