Buggy python submission (verdict: Runtime Error):
n,m=map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]

ans = ['0']*(m+1)
for i in range(len(sc)):
    if ans[sc[i][0]] == '0' or ans[sc[i][0]] >= str(sc[i][1]):
        if sc[i][1] != 0:
            ans[sc[i][0]] = str(sc[i][1])
    else:
        continue
if ans[1] == '0':
    print(-1)
else:
    print(int(''.join(ans)))


Fixed submission:
n,m=map(int, input().split())
sc = [list(map(int, input().split())) for x in range(m)]

ans = ['0']*(n+1)
flg = 0
for i in range(m):
    if ans[sc[i][0]] == '0':
        if sc[i][1] != 0:
            ans[sc[i][0]] = str(sc[i][1])
            if sc[i][0] == 1:
                flg = 1
        elif sc[i][0] == 1 and sc[i][1] == 0 and flg == 0:
            ans[sc[i][0]] = str(sc[i][1])
            flg = 1
        else:
            continue
    elif ans[sc[i][0]] == str(sc[i][1]):
        continue
    else:
        print(-1)
        exit()
if flg == 0 and len(ans) != 2:
    ans[1] = '1'
    print(int(''.join(ans)))
elif ans[1] == '0' and len(ans) != 2:
    print(-1)
else:
    print(int(''.join(ans)))

Buggy python submission (verdict: Runtime Error):
n,m=map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]

ans = ['0']*(m+1)
for i in range(len(sc)):
    if ans[sc[i][0]] == '0' or ans[sc[i][0]] >= str(sc[i][1]):
        ans[sc[i][0]] = str(sc[i][1])
    else:
        continue
if ans[1] == '0':
    print(-1)
else:
    print(int(''.join(ans)))

Fixed submission:
n,m=map(int, input().split())
sc = [list(map(int, input().split())) for x in range(m)]

ans = ['0']*(n+1)
flg = 0
for i in range(m):
    if ans[sc[i][0]] == '0':
        if sc[i][1] != 0:
            ans[sc[i][0]] = str(sc[i][1])
            if sc[i][0] == 1:
                flg = 1
        elif sc[i][0] == 1 and sc[i][1] == 0 and flg == 0:
            ans[sc[i][0]] = str(sc[i][1])
            flg = 1
        else:
            continue
    elif ans[sc[i][0]] == str(sc[i][1]):
        continue
    else:
        print(-1)
        exit()
if flg == 0 and len(ans) != 2:
    ans[1] = '1'
    print(int(''.join(ans)))
elif ans[1] == '0' and len(ans) != 2:
    print(-1)
else:
    print(int(''.join(ans)))

Buggy python submission (verdict: Runtime Error):
n,m=map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]

ans = ['0']*(m+1)
for i in range(len(sc)):
    if ans[sc[i][0]] == '0' or ans[sc[i][0]] == str(sc[i][1]):
        ans[sc[i][0]] = str(sc[i][1])
    else:
        print(-1)
        exit()
if ans[1] == '0':
    print(-1)
else:
    print(int(''.join(ans)))

Fixed submission:
n,m=map(int, input().split())
sc = [list(map(int, input().split())) for x in range(m)]

ans = ['0']*(n+1)
flg = 0
for i in range(m):
    if ans[sc[i][0]] == '0':
        if sc[i][1] != 0:
            ans[sc[i][0]] = str(sc[i][1])
            if sc[i][0] == 1:
                flg = 1
        elif sc[i][0] == 1 and sc[i][1] == 0 and flg == 0:
            ans[sc[i][0]] = str(sc[i][1])
            flg = 1
        else:
            continue
    elif ans[sc[i][0]] == str(sc[i][1]):
        continue
    else:
        print(-1)
        exit()
if flg == 0 and len(ans) != 2:
    ans[1] = '1'
    print(int(''.join(ans)))
elif ans[1] == '0' and len(ans) != 2:
    print(-1)
else:
    print(int(''.join(ans)))