Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(raw_input())
for i in range(n):
    A = map(int, raw_input().split())
    B = []
    C = []
    flag = True
    for i in range(5):
        B.append(A[2*i])
        C.append(A[2*i+1])
    for i in range(4):
        for j in range(i+1, 4)
            if B[j] > B[i]:
                flag = False
                break
            if C[ij > C[i]:
                flag = False
                break
    if flag:
        print "YES"
    else:
        print "NO"

Fixed submission:
# -*- coding: utf-8 -*-

n = int(raw_input())
for i in range(n):
    A, B, C = [], [0], [0]
    A = map(int, raw_input().split())
    for i in range(10):
        if A[i] > B[0]:
            B.insert(0, A[i])
        elif A[i] > C[0]:
            C.insert(0, A[i])
        else:
            break
    if len(B) + len(C) == 12:
        print "YES"
    else:
        print "NO"

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(raw_input())
for i in range(n):
    A = map(int, raw_input().split())
    B = []
    C = []
    flag = True
    for i in range(5):
        B.append(A[2*i])
        C.append(A[2*i+1])
    for i in range(4):
        for j in range(i+1, 5)
            if B[j] > B[i]:
                flag = False
                break
            if C[j] > C[i]:
                flag = False
                break
    if flag:
        print "YES"
    else:
        print "NO"

Fixed submission:
# -*- coding: utf-8 -*-

n = int(raw_input())
for i in range(n):
    A, B, C = [], [0], [0]
    A = map(int, raw_input().split())
    for i in range(10):
        if A[i] > B[0]:
            B.insert(0, A[i])
        elif A[i] > C[0]:
            C.insert(0, A[i])
        else:
            break
    if len(B) + len(C) == 12:
        print "YES"
    else:
        print "NO"

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(raw_input())
for i in range(n):
    A, B, C = [], [0], [0]
    A = map(int, raw_input().split())
    for i in range(10):
        if num[i] > A[0]:
            A.insert(0, num[i])
        elif num[i] > B[0]:
            B.insert(0, num[i])
        else:
            break
    if len(A) + len(B) == 12:
        print "YES"
    else:
        print "NO"

Fixed submission:
# -*- coding: utf-8 -*-

n = int(raw_input())
for i in range(n):
    A, B, C = [], [0], [0]
    A = map(int, raw_input().split())
    for i in range(10):
        if A[i] > B[0]:
            B.insert(0, A[i])
        elif A[i] > C[0]:
            C.insert(0, A[i])
        else:
            break
    if len(B) + len(C) == 12:
        print "YES"
    else:
        print "NO"

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(raw_input())
for i in range(n):
    A, B, C = [], [0], [0]
    A = map(int, raw_input().split())
    for i in range(10):
        if A[i] > B[0]:
            B.insert(0, num[i])
        elif A[i] > C[0]:
            C.insert(0, num[i])
        else:
            break
    if len(A) + len(B) == 12:
        print "YES"
    else:
        print "NO"

Fixed submission:
# -*- coding: utf-8 -*-

n = int(raw_input())
for i in range(n):
    A, B, C = [], [0], [0]
    A = map(int, raw_input().split())
    for i in range(10):
        if A[i] > B[0]:
            B.insert(0, A[i])
        elif A[i] > C[0]:
            C.insert(0, A[i])
        else:
            break
    if len(B) + len(C) == 12:
        print "YES"
    else:
        print "NO"