def reduce(num):
    explodeCriteriaMet = True
    splitCriteriaMet = True
    while (explodeCriteriaMet or splitCriteriaMet):
        explodeCriteriaMet = False
        splitCriteriaMet = False
        for (idx1, val1) in enumerate(num):
            if explodeCriteriaMet:
                break
            if (type(val1) == list):
                for (idx2, val2) in enumerate(val1):
                    if explodeCriteriaMet:
                        break
                    if (type(val2) == list):
                        for (idx3, val3) in enumerate(val2):
                            if explodeCriteriaMet:
                                break
                            if (type(val3) == list):
                                for (idx4, val4) in enumerate(val3):
                                    if (type(val4) == list):
                                        explodeCriteriaMet = True
                                        num = explode(num, val4, [idx1, idx2, idx3, idx4])
                                        break
        if explodeCriteriaMet:
            continue
        for (idx1, val1) in enumerate(num):
            if splitCriteriaMet:
                break
            if (type(val1) == list):
                for (idx2, val2) in enumerate(val1):
                    if splitCriteriaMet:
                        break
                    if (type(val2) == list):
                        for (idx3, val3) in enumerate(val2):
                            if splitCriteriaMet:
                                break
                            if (type(val3) == list):
                                for (idx4, val4) in enumerate(val3):
                                    if (val4 >= 10):
                                        splitCriteriaMet = True
                                        num = split(num, val4, [idx1, idx2, idx3, idx4])
                                        break
                            elif (val3 >= 10):
                                splitCriteriaMet = True
                                num = split(num, val3, [idx1, idx2, idx3])
                                break
                    elif (val2 >= 10):
                        splitCriteriaMet = True
                        num = split(num, val2, [idx1, idx2])
                        break
            elif (val1 >= 10):
                splitCriteriaMet = True
                num = split(num, val1, [idx1])
                break
    return num
def reduce(num):
    explodeCriteriaMet = True
    splitCriteriaMet = True
    while (explodeCriteriaMet or splitCriteriaMet):
        explodeCriteriaMet = False
        splitCriteriaMet = False
        for (idx1, val1) in enumerate(num):
            if explodeCriteriaMet:
                break
            if (type(val1) == list):
                for (idx2, val2) in enumerate(val1):
                    if explodeCriteriaMet:
                        break
                    if (type(val2) == list):
                        for (idx3, val3) in enumerate(val2):
                            if explodeCriteriaMet:
                                break
                            if (type(val3) == list):
                                for (idx4, val4) in enumerate(val3):
                                    if (type(val4) == list):
                                        explodeCriteriaMet = True
                                        num = explode(num, val4, [idx1, idx2, idx3, idx4])
                                        break
        if explodeCriteriaMet:
            continue
        for (idx1, val1) in enumerate(num):
            if splitCriteriaMet:
                break
            if (type(val1) == list):
                for (idx2, val2) in enumerate(val1):
                    if splitCriteriaMet:
                        break
                    if (type(val2) == list):
                        for (idx3, val3) in enumerate(val2):
                            if splitCriteriaMet:
                                break
                            if (type(val3) == list):
                                for (idx4, val4) in enumerate(val3):
                                    if (val4 >= 10):
                                        splitCriteriaMet = True
                                        num = split(num, val4, [idx1, idx2, idx3, idx4])
                                        break
                            elif (val3 >= 10):
                                splitCriteriaMet = True
                                num = split(num, val3, [idx1, idx2, idx3])
                                break
                    elif (val2 >= 10):
                        splitCriteriaMet = True
                        num = split(num, val2, [idx1, idx2])
                        break
            elif (val1 >= 10):
                splitCriteriaMet = True
                num = split(num, val1, [idx1])
                break
    return num