Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = [-1] * n

exist = True

if n == 1:
    sc_list = []
    for i in range(m):
        sc_list.append(list(map(int, input().split())))
    if m >= 2:
        for j in range(m-1):
            if sc_list[j][1] != sc_list[j+1][1]:
                exist = False
    if exist:
        x = str(sc_list[0][1])

elif n >= 2:
    for i in range(m):
        s, c = map(int, input().split())
        if s == 1:
            if c == 0:
                exist = False
            else:
                if x[0] != -1 and x[0] != c:
                    exist = False
                else:
                    x[0] = c
        else:
            if x[s-1] != -1 and x[s-1] != c:
                exist = False
            else:
                x[s-1] = c

    if x[0] == -1:
        exist = False
    if exist:
        x = [0 if j == -1 else j for j in x]
        x = "".join(map(str,x))
            
if exist:
    print(x)
else:
    print(-1)


Fixed submission:
n, m = map(int, input().split())

exist = True

if n == 1:
    sc_list = []
    for i in range(m):
        sc_list.append(list(map(int, input().split())))
    
    if m >= 2:
        for j in range(m-1):
            if sc_list[j][1] != sc_list[j+1][1]:
                exist = False
    
    if exist:
        if m >= 1:
            x = str(sc_list[0][1])
        elif m == 0:
            x = '0'

elif n >= 2:
    x = [-1] * n

    for i in range(m):
        s, c = map(int, input().split())
        if s == 1:
            if c == 0:
                exist = False
            else:
                if x[0] != -1 and x[0] != c:
                    exist = False
                else:
                    x[0] = c
        else:
            if x[s-1] != -1 and x[s-1] != c:
                exist = False
            else:
                x[s-1] = c

    if x[0] == -1 :
        x[0] = 1
    if exist:
        x = [0 if j == -1 else j for j in x]
        x = "".join(map(str,x))
            
if exist:
    print(x)
else:
    print('-1')

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = [-1] * n

exist = True

if n == 1:
    sc_list = []
    for i in range(m):
        sc_list.append(list(map(int, input().split())))
    if m >= 2:
        for i in range(m-1):
            if sc_list[i][1] != sc_list[i+1][1]:
                exist = False
    if exist:
        x = str(sc_list[0][1])

elif n >= 2:
    for i in range(m):
        s, c = map(int, input().split())
        if s == 1:
            if c == 0:
                exist = False
            else:
                if x[0] != -1 and x[0] != c:
                    exist = False
                else:
                    x[0] = c
        else:
            if x[s-1] != -1 and x[s-1] != c:
                exist = False
            else:
                x[s-1] = c

    if x[0] == -1:
        exist = False
    if exist:
        x = [0 if j == -1 else j for j in x]
        x = "".join(map(str,x))
            
if exist:
    print(x)
else:
    print(-1)


Fixed submission:
n, m = map(int, input().split())

exist = True

if n == 1:
    sc_list = []
    for i in range(m):
        sc_list.append(list(map(int, input().split())))
    
    if m >= 2:
        for j in range(m-1):
            if sc_list[j][1] != sc_list[j+1][1]:
                exist = False
    
    if exist:
        if m >= 1:
            x = str(sc_list[0][1])
        elif m == 0:
            x = '0'

elif n >= 2:
    x = [-1] * n

    for i in range(m):
        s, c = map(int, input().split())
        if s == 1:
            if c == 0:
                exist = False
            else:
                if x[0] != -1 and x[0] != c:
                    exist = False
                else:
                    x[0] = c
        else:
            if x[s-1] != -1 and x[s-1] != c:
                exist = False
            else:
                x[s-1] = c

    if x[0] == -1 :
        x[0] = 1
    if exist:
        x = [0 if j == -1 else j for j in x]
        x = "".join(map(str,x))
            
if exist:
    print(x)
else:
    print('-1')

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = [-1] * n

exist = True

if n == 1:
    sc_list = []
    for i in range(m):
        sc_list.append(list(map(int, input().split())))
    for i in range(m-1):
        if sc_list[i][1] != sc_list[i+1][1]:
            exist = False
    if exist:
        x = str(sc_list[0][1])

elif n >= 2:
    for i in range(m):
        s, c = map(int, input().split())
        if s == 1:
            if c == 0:
                exist = False
            else:
                if x[0] != -1 and x[0] != c:
                    exist = False
                else:
                    x[0] = c
        else:
            if x[s-1] != -1 and x[s-1] != c:
                exist = False
            else:
                x[s-1] = c

    if x[0] == -1:
        exist = False
    if exist:
        x = [0 if j == -1 else j for j in x]
        x = "".join(map(str,x))
            
if exist:
    print(x)
else:
    print(-1)


Fixed submission:
n, m = map(int, input().split())

exist = True

if n == 1:
    sc_list = []
    for i in range(m):
        sc_list.append(list(map(int, input().split())))
    
    if m >= 2:
        for j in range(m-1):
            if sc_list[j][1] != sc_list[j+1][1]:
                exist = False
    
    if exist:
        if m >= 1:
            x = str(sc_list[0][1])
        elif m == 0:
            x = '0'

elif n >= 2:
    x = [-1] * n

    for i in range(m):
        s, c = map(int, input().split())
        if s == 1:
            if c == 0:
                exist = False
            else:
                if x[0] != -1 and x[0] != c:
                    exist = False
                else:
                    x[0] = c
        else:
            if x[s-1] != -1 and x[s-1] != c:
                exist = False
            else:
                x[s-1] = c

    if x[0] == -1 :
        x[0] = 1
    if exist:
        x = [0 if j == -1 else j for j in x]
        x = "".join(map(str,x))
            
if exist:
    print(x)
else:
    print('-1')

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = [0] * n

exist = True

if n == 1:
    sc_list = []
    for i in range(m):
        sc_list.append(list(map(int, input().split())))
    for i in range(m-1):
        if sc_list[i][1] != sc_list[i+1][1]:
            exist = False
    if exist:
        x = [sc_list[0][1]]

elif n >= 2:
    for i in range(m):
        s, c = map(int, input().split())
        if s == 1:
            if c == 0:
                exist = False
            else:
                if x[0] != 0 and x[0] != c:
                    exist = False
                else:
                    x[0] = c
        else:
            if x[s-1] != 0 and x[s-1] != c:
                exist = False
            else:
                x[s-1] = c

if n >= 2 and x[0] == 0:
    exist = False
            
if exist:
    print("".join(map(str,x)))
else:
    print(-1)


Fixed submission:
n, m = map(int, input().split())

exist = True

if n == 1:
    sc_list = []
    for i in range(m):
        sc_list.append(list(map(int, input().split())))
    
    if m >= 2:
        for j in range(m-1):
            if sc_list[j][1] != sc_list[j+1][1]:
                exist = False
    
    if exist:
        if m >= 1:
            x = str(sc_list[0][1])
        elif m == 0:
            x = '0'

elif n >= 2:
    x = [-1] * n

    for i in range(m):
        s, c = map(int, input().split())
        if s == 1:
            if c == 0:
                exist = False
            else:
                if x[0] != -1 and x[0] != c:
                    exist = False
                else:
                    x[0] = c
        else:
            if x[s-1] != -1 and x[s-1] != c:
                exist = False
            else:
                x[s-1] = c

    if x[0] == -1 :
        x[0] = 1
    if exist:
        x = [0 if j == -1 else j for j in x]
        x = "".join(map(str,x))
            
if exist:
    print(x)
else:
    print('-1')