Тема: задача Matching Brackets codeabbey
Ось сама задача - https://www.codeabbey.com/index/task_vi … g-brackets
Мій розв'язок
out = []
for w in range(int(input())):
    k = 1
    x = []
    inp = list("".join(x for x in input() if x in ("{}[]()<>")))
    for i in inp:
        if i == "(":
            x.append(")")
        elif i == "[":
            x.append("]")
        elif i == "{":
            x.append("}")
        elif i == "<":
            x.append(">")
        elif len(x) == 0:
            k -= 1
        elif i == x[len(x) - 1]:
            x.pop(len(x) - 1)
        else:
            k -= 1
    if len(x) != 0:
        out.append("0")
    elif k == 1: 
        out.append("1")
    else:
        out.append("0")
        
print(" ".join(out))В компіляторі все працює, а на codeabbey просто не вираховує відповідь (тобто в полі де має обрахуватися результат безкінечно виводить крапки, ніби вираховує).
Допоможіть будь ласка вирішити проблему.