Buggy python submission (verdict: Runtime Error):
import sys

input = map(lambda x:x[:-1], sys.stdin.readlines())


n = int(input[0])

input = input[1:]

input = map(lambda x:x.split(' '), input)

for i in range(len(input)):
    input[i] = map(lambda x:int(x), input[i])

print input
A = []
B = []

def a_can_add(e):
    if ((len(A) != 0) and (A[-1] < e)) or len(A) == 0:
        return True    

def b_can_add(e):
    if ((len(B) != 0) and (B[-1] < e)) or len(B) == 0:
        return True

def a_add(e):
    if (len(A) != 0) and (A[-1] < e):
        A.append(e)
    elif len(A) == 0:
        A.append(e)
    else: return False

def b_add(e):
    if len(B) != 0 and (B[-1] < e):
        B.append(e)
    elif len(B) == 0:
        B.append(e)
    else: return False


for i in range(len(input)):
    for j in range(10):
        if a_can_add(input[i][j]):
            a_add(input[i][j])
        elif b_can_add(input[i][j]):
            b_add(input[i][j])
            
    if len(A) + len(B) == 10:
        print "YES"
    else:
        print "NO"

Fixed submission:
N = int(raw_input())

def dfs(depth, l, r):
    if depth == 10:
        return True

    if l < A[depth] and dfs(depth+1, A[depth], r):
        return True
    if r < A[depth] and dfs(depth+1, l, A[depth]):
        return True

    return False

for c in range(N):
    A = map(int, raw_input().split(" "))
    if dfs(0, 0, 0):
        print "YES"
    else:
        print "NO"

Buggy python submission (verdict: Runtime Error):
import sys

input = map(lambda x:x[:-1], sys.stdin.readlines())


n = int(input[0])

input = input[1:]

input = map(lambda x:x.split(' '), input)

for i in range(len(input)):
    input[i] = map(lambda x:int(x), input[i])

print input
A = []
B = []

def a_can_add(e):
    if ((len(A) != 0) and (A[-1] < e)) or len(A) == 0:
        return True    

def b_can_add(e):
    if ((len(B) != 0) and (B[-1] < e)) or len(B) == 0:
        return True

def a_add(e):
    if (len(A) != 0) and (A[-1] < e):
        A.append(e)
    elif len(A) == 0:
        A.append(e)
    else: return False

def b_add(e):
    if len(B) != 0 and (B[-1] < e):
        B.append(e)
    elif len(B) == 0:
        B.append(e)
    else: return False


for i in range(len(input)):
    for j in range(10):
        if a_can_add(input[i][j]):
            a_add(input[i][j])
        elif b_can_add(input[i][j]):
            b_add(input[i][j])
            
    if len(A) + len(B) == 10:
        print "YES"
    else:
        print "NO"

Fixed submission:
N = int(raw_input())

def dfs(depth, l, r):
    if depth == 10:
        return True

    if l < A[depth] and dfs(depth+1, A[depth], r):
        return True
    if r < A[depth] and dfs(depth+1, l, A[depth]):
        return True

    return False

for c in range(N):
    A = map(int, raw_input().split(" "))
    if dfs(0, 0, 0):
        print "YES"
    else:
        print "NO"

Buggy python submission (verdict: Runtime Error):
import sys

input = map(lambda x:x[:-1], sys.stdin.readlines())


n = int(input[0])

input = input[1:]

input = map(lambda x:x.split(' '), input)

for i in range(len(input)):
    input[i] = map(lambda x:int(x), input[i])

#print input
A = []
B = []

def a_can_add(e):
    if ((len(A) != 0) and (A[-1] < e)) or len(A) == 0:
        return True    

def b_can_add(e):
    if ((len(B) != 0) and (B[-1] < e)) or len(B) == 0:
        return True

def a_add(e):
    if (len(A) != 0) and (A[-1] < e):
        A.append(e)
    elif len(A) == 0:
        A.append(e)
    else: return False

def b_add(e):
    if len(B) != 0 and (B[-1] < e):
        B.append(e)
    elif len(B) == 0:
        B.append(e)
    else: return False


for i in range(len(input)):
    for j in range(10):
        if a_can_add(input[i][j]):
            a_add(input[i][j])
        elif b_can_add(input[i][j]):
            b_add(input[i][j])
            
    if len(A) + len(B) == 10:
        print "YES"
    else:
        print "NO"

Fixed submission:
N = int(raw_input())

def dfs(depth, l, r):
    if depth == 10:
        return True

    if l < A[depth] and dfs(depth+1, A[depth], r):
        return True
    if r < A[depth] and dfs(depth+1, l, A[depth]):
        return True

    return False

for c in range(N):
    A = map(int, raw_input().split(" "))
    if dfs(0, 0, 0):
        print "YES"
    else:
        print "NO"