Buggy python submission (verdict: Runtime Error):
5
1 2 3 3 4 5 7 7 7
R R R R R R G G G
1 2 2 3 4 4 4 4 5
R R R R R R R R R
1 2 3 4 4 4 5 5 5
R R B R R R R R R
1 1 1 3 4 5 6 6 6
R R B G G G R R R
2 2 2 3 3 3 1 1 1
R G B R G B R G B


Fixed submission:
T = int(input())
for i in range(T):
    num = list(map(int, input().split()))
    coler = input().split()
    groups = [[], [], []]
    for i, c in enumerate(coler):
        if c == "R":
            groups[0].append(num[i])
        elif c == "G":
            groups[1].append(num[i])
        else:
            groups[2].append(num[i])
    for group in groups:
        while len(group) != 0 and len(group) % 3 == 0:
            tmp = group[:]
            group.sort()
            i = group[0]
            if group.count(i) >= 3:
                for _ in range(3):
                    group.remove(i)
            if i + 1 in group and i + 2 in group:
                for j in range(3):
                    group.remove(i + j)
            if tmp == group:
                break
    if len(groups[0]) == len(groups[1]) == len(groups[2]) == 0:
        print(1)
    else:
        print(0)

Buggy python submission (verdict: Runtime Error):
T = int(input())
for i in range(T):
    num = list(map(int, input().split()))
    coler = input().split()
    groups = [[], [], []]
    for i, c in enumerate(coler):
        if c == "R":
            groups[0].append(num[i])
        elif c == "G":
            groups[1].append(num[i])
        else:
            groups[2].append(num[i])
    for group in groups:
        while len(group) != 0 and len(group) % 3 == 0:
            tmp = group[:]
            group.sort()
            i = group[0]
            if group.count(i) >= 3:
                for _ in range(3):
                    group.remove(i)
            if i + 1 in group and i + 2 in group:
                for j in range(3):
                    group.remove(i + j)
            if tmp == group:
                break
    if len(groups[0]) == len(groups[1]) == len(groups[2]) == 0:
        print(1)
    else:
        print(0)


Fixed submission:
T = int(input())
for i in range(T):
    num = list(map(int, input().split()))
    coler = input().split()
    groups = [[], [], []]
    for i, c in enumerate(coler):
        if c == "R":
            groups[0].append(num[i])
        elif c == "G":
            groups[1].append(num[i])
        else:
            groups[2].append(num[i])
    for group in groups:
        while len(group) != 0 and len(group) % 3 == 0:
            tmp = group[:]
            group.sort()
            i = group[0]
            if group.count(i) >= 3:
                for _ in range(3):
                    group.remove(i)
            if i + 1 in group and i + 2 in group:
                for j in range(3):
                    group.remove(i + j)
            if tmp == group:
                break
    if len(groups[0]) == len(groups[1]) == len(groups[2]) == 0:
        print(1)
    else:
        print(0)

Buggy python submission (verdict: Runtime Error):
T = int(input())
for i in range(T):
    num = list(map(int, input().split()))
    coler = input().split()
    groups = [[], [], []]
    for i, c in enumerate(coler):
        if c == "R":
            groups[0].append(num[i])
        elif c == "G":
            groups[1].append(num[i])
        else:
            groups[2].append(num[i])
    for group in groups:
        while len(group) != 0 and len(group) % 3 == 0:
            tmp = group[:]
            group.sort()
            i = group[0]
            if group.count(i) >= 3:
                for _ in range(3):
                    group.remove(i)
            if i + 1 in group and i + 2 in group:
                for j in range(3):
                    group.remove(i + j)
            if tmp == group:
                break
    if len(groups[0]) == len(groups[1]) == len(groups[2]) == 0:
        print(1)
    else:
        print(0)


Fixed submission:
T = int(input())
for i in range(T):
    num = list(map(int, input().split()))
    coler = input().split()
    groups = [[], [], []]
    for i, c in enumerate(coler):
        if c == "R":
            groups[0].append(num[i])
        elif c == "G":
            groups[1].append(num[i])
        else:
            groups[2].append(num[i])
    for group in groups:
        while len(group) != 0 and len(group) % 3 == 0:
            tmp = group[:]
            group.sort()
            i = group[0]
            if group.count(i) >= 3:
                for _ in range(3):
                    group.remove(i)
            if i + 1 in group and i + 2 in group:
                for j in range(3):
                    group.remove(i + j)
            if tmp == group:
                break
    if len(groups[0]) == len(groups[1]) == len(groups[2]) == 0:
        print(1)
    else:
        print(0)