def check_basic(test_case):
    depth = 0
    stack = []
    errors = []
    test_case = test_case.split('\n')
    indent_char = test_case[1]
    test_case = test_case[2:]
    expected = {'NEXT': 'FOR', 'ENDIF': 'IF'}
    for line_num, line in enumerate(test_case, 1):
        newline = line.strip(r'·» \t\s')
        if newline and not newline.isdigit():
            if any(newline.startswith(key) for key in expected):
                block_end = newline.split()[0]
                if not stack or expected[block_end] != stack.pop():
                    errors.append('Error in line number {}: {} found when another close was expected'.format(line_num, block_end))
                    depth = depth - 1 if depth >= 1 else 0
                depth = depth - 1 if depth >= 1 else 0
            print((indent_char * depth) + newline)
            if any(newline.startswith(value) for value in expected.values()):
                stack.append(newline.split()[0])
                depth += 1

    if stack:
        print('Error: There was a problem closing the following block(s): {}'.format(', '.join(stack)))
    if errors:
        print('\n'.join(errors))

print('\n--------       Test case 1:        --------')
input1 = """12
····
VAR I
·FOR I=1 TO 31
»»»»IF !(I MOD 3) THEN
··PRINT "FIZZ"
··»»ENDIF
»»»»····IF !(I MOD 5) THEN
»»»»··PRINT "BUZZ"
··»»»»»»ENDIF
»»»»IF (I MOD 3) && (I MOD 5) THEN
······PRINT "FIZZBUZZ"
··»»ENDIF
»»»»·NEXT
"""
check_basic(input1)

print('\n--------       Test case 2:        --------')
print('-------- (using asterix as indent) --------')
input2 = """10
****
FOR I=0 TO 10
····IF I MOD 2 THEN
········PRINT I
NEXT
FOR I=0 TO 10
····IF I MOD 2 THEN
········PRINT I
FOR I=0 TO 10
····PRINT I
ENDIF
"""
check_basic(input2)