Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
sc = {}
flag = False
smax = 0
for i in range(M):
    s,c = map(int,input().split())
    smax = max(s,smax)
    if s > N:
        flag = True
        break
    elif s not in sc:
        sc[s] = c
    else:
        if sc[s] != c:
            flag = True
            break
if flag:
    print(-1)
else:
    ans = [0 for i in range(smax)]
    for s,c in sc.items():
        ans[s-1] = c
    if ans[0] == 0:
        print(-1)
    else:
        print(*ans,sep='')

Fixed submission:
N,M = map(int,input().split())
sc = {}
flag = False
for i in range(M):
    s,c = map(int,input().split())
    if N!=1 and s==1 and c == 0:
        flag =True
        break
    elif s not in sc:
        sc[s] = c
    else:
        if sc[s] != c:
            flag = True
            break
if flag:
    print(-1)
elif N == 1 and M == 0:
    print(0)
else:
    if N == 1:
        print(sc[1])
    else:
        ans = [0 for i in range(N)]
        ans[0] = 1

        for s,c in sc.items():
            ans[s-1] = c
        print(*ans,sep='')
        print()

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(M)]
c = [i[1] for i in sc]
s = [i[0] for i in sc]
smax = max(s)
sc2 = [-1 for i in range(smax)]
flag = False
for s1,c1 in sc:
    if sc2[s1-1] == -1:
        sc2[s1-1] = c1
    else:
        flag = True
        break
if -1 in sc2:
    num = 0
else:
    num = int(''.join(map(str,sc2)))
if smax > N or flag or num == 0:
    print(-1)
else:
    if N == 1:
        if num <= 9:
            print(num)
    else:
        rem = N-smax
        print(str(num) + '0'*rem)
        

Fixed submission:
N,M = map(int,input().split())
sc = {}
flag = False
for i in range(M):
    s,c = map(int,input().split())
    if N!=1 and s==1 and c == 0:
        flag =True
        break
    elif s not in sc:
        sc[s] = c
    else:
        if sc[s] != c:
            flag = True
            break
if flag:
    print(-1)
elif N == 1 and M == 0:
    print(0)
else:
    if N == 1:
        print(sc[1])
    else:
        ans = [0 for i in range(N)]
        ans[0] = 1

        for s,c in sc.items():
            ans[s-1] = c
        print(*ans,sep='')
        print()

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(M)]
c = [i[1] for i in sc]
s = [i[0] for i in sc]
smax = max(s)
sc2 = [-1 for i in range(smax)]
flag = False
for s1,c1 in sc:
    if sc2[s1-1] == -1:
        sc2[s1-1] = c1
    else:
        flag = True
        break
num = int(''.join(map(str,sc2)))
if smax > N or flag or num == 0:
    print(-1)
else:
    if N == 1:
        if num <= 9:
            print(num)
    else:
        rem = N-smax
        print(str(num) + '0'*rem)
        

Fixed submission:
N,M = map(int,input().split())
sc = {}
flag = False
for i in range(M):
    s,c = map(int,input().split())
    if N!=1 and s==1 and c == 0:
        flag =True
        break
    elif s not in sc:
        sc[s] = c
    else:
        if sc[s] != c:
            flag = True
            break
if flag:
    print(-1)
elif N == 1 and M == 0:
    print(0)
else:
    if N == 1:
        print(sc[1])
    else:
        ans = [0 for i in range(N)]
        ans[0] = 1

        for s,c in sc.items():
            ans[s-1] = c
        print(*ans,sep='')
        print()