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

ans = [10 for i in range(n)]

sc.sort()

ini_pos = sc[0][0]
ini_val = sc[0][1]
ans[ini_pos-1] = ini_val

for i in range(m-1):
    if sc[i+1][0] == ini_pos:
        if sc[i+1][1] != ini_val:
            print(-1)
            exit()
    else:
        ini_pos = sc[i+1][0]
        ini_val = sc[i+1][1]
        ans[ini_pos-1] = ini_val

if ans[0] == 0:
    if n == 1:
        print(0)
        exit()
    else:
        print(-1)
        exit()

value = 0

for i in range(n):
    if ans[i] != 10:
        value += ans[i] * 10 ** (n-i-1)

print(value)

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

if m == 0:
    if n == 3:
        print(100)
        exit()
    elif n == 2:
        print(10)
        exit()
    elif n== 1:
        print(0)
        exit()

ans = [10 for i in range(n)]

sc.sort()

ini_pos = sc[0][0]
ini_val = sc[0][1]
ans[ini_pos-1] = ini_val

for i in range(m-1):
    if sc[i+1][0] == ini_pos:
        if sc[i+1][1] != ini_val:
            print(-1)
            exit()
    else:
        ini_pos = sc[i+1][0]
        ini_val = sc[i+1][1]
        ans[ini_pos-1] = ini_val

if ans[0] == 0:
    if n == 1:
        print(0)
        exit()
    else:
        print(-1)
        exit()

value = 0

for i in range(n):
    if i == 0:
        if ans[i] == 10:
            value += 10 ** (n-i-1)
            continue
    if ans[i] != 10:
        value += ans[i] * 10 ** (n-i-1)

print(value)

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

ans = [10 for i in range(3)]

sc.sort()

ini_pos = sc[0][0]
ini_val = sc[0][1]
ans[ini_pos-1] = ini_val

for i in range(m-1):
    if sc[i+1][0] == ini_pos:
        if sc[i+1][1] != ini_val:
            print(-1)
            exit()
    else:
        ini_pos = sc[i+1][0]
        ini_val = sc[i+1][1]
        ans[ini_pos-1] = ini_val

if ans[0] == 0:
    print(-1)
    exit()

value = 0

for i in range(n):
    if ans[i] != 10:
        value += ans[i] * 10 ** (n-i-1)

print(value)

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

if m == 0:
    if n == 3:
        print(100)
        exit()
    elif n == 2:
        print(10)
        exit()
    elif n== 1:
        print(0)
        exit()

ans = [10 for i in range(n)]

sc.sort()

ini_pos = sc[0][0]
ini_val = sc[0][1]
ans[ini_pos-1] = ini_val

for i in range(m-1):
    if sc[i+1][0] == ini_pos:
        if sc[i+1][1] != ini_val:
            print(-1)
            exit()
    else:
        ini_pos = sc[i+1][0]
        ini_val = sc[i+1][1]
        ans[ini_pos-1] = ini_val

if ans[0] == 0:
    if n == 1:
        print(0)
        exit()
    else:
        print(-1)
        exit()

value = 0

for i in range(n):
    if i == 0:
        if ans[i] == 10:
            value += 10 ** (n-i-1)
            continue
    if ans[i] != 10:
        value += ans[i] * 10 ** (n-i-1)

print(value)

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

ans = [10 for i in range(3)]

sc.sort()

ini_pos = sc[0][0]
ini_val = sc[0][1]
ans[ini_pos-1] = ini_val

for i in range(m-1):
    if sc[i+1][0] == ini_pos:
        if sc[i+1][1] != ini_val:
            print(-1)
            exit()
    else:
        ini_pos = sc[i+1][0]
        ini_val = sc[i+1][1]
        ans[ini_pos-1] = ini_val

if ans[0] == 0:
    print(-1)
    exit()

value = 0

for i in range(3):
    if ans[i] != 10:
        value += ans[i] * 10 ** (2-i)

print(value)

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

if m == 0:
    if n == 3:
        print(100)
        exit()
    elif n == 2:
        print(10)
        exit()
    elif n== 1:
        print(0)
        exit()

ans = [10 for i in range(n)]

sc.sort()

ini_pos = sc[0][0]
ini_val = sc[0][1]
ans[ini_pos-1] = ini_val

for i in range(m-1):
    if sc[i+1][0] == ini_pos:
        if sc[i+1][1] != ini_val:
            print(-1)
            exit()
    else:
        ini_pos = sc[i+1][0]
        ini_val = sc[i+1][1]
        ans[ini_pos-1] = ini_val

if ans[0] == 0:
    if n == 1:
        print(0)
        exit()
    else:
        print(-1)
        exit()

value = 0

for i in range(n):
    if i == 0:
        if ans[i] == 10:
            value += 10 ** (n-i-1)
            continue
    if ans[i] != 10:
        value += ans[i] * 10 ** (n-i-1)

print(value)