Buggy python submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())

C = []
S = []

for i in range(M):
    c, s = map(int, input().split())
    C.append(c)
    S.append(s)

for x in range(1000):
    keta = 1
    nx = x//10
    d = [x%10]


    while(nx):
        keta += 1
        d.append(nx%10)
        nx = nx // 10
    d = list(reversed(d))

    isOk = True
    
    for i in range(M):
        if( d[C[i]-1] != S[i-1] ):
            isOk = False

    if isOk :
        num = "".join(map(str, d))
        break

if isOk:
    print(num)
else:
    print(-1)

Fixed submission:
N, M = map(int, input().split())

ans = [0 for i in range(N)]
isTerms = [0 for i in range(N)]
jadge = True

for i in range(M):
    s, c = map(int, input().split())
    if( ans[s-1] != c and isTerms[s-1] != 0):
        jadge = False
    elif( s == 1 and c == 0):
        jadge = False
    else:
        ans[s-1] = c
        isTerms[s-1] = 1

if( N != 1 and ans[0] == 0 and jadge):
    ans[0] = 1

if( N == 1 and ans[0] == 0):
    jadge = True

if jadge:
    if(N==1):
        print(ans[0])
    else:
        for i in range(N-1):
            print(ans[i] ,end = "")
        print(ans[i+1])
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())

C = []
S = []

for i in range(M):
    c, s = map(int, input().split())
    C.append(c)
    S.append(s)

for x in range(1000):
    keta = 1
    nx = x//10
    d = [x%10]


    while(nx):
        keta += 1
        d.append(nx%10)
        nx = nx // 10
    d = list(reversed(d))

    isOk = True
    
    for i in range(M):
        if( d[C[i]-1] != S[i-1] ):
            isOk = False

    if isOk :
        num = "".join(map(str, d))
        print(num)
        sys.exit

print(-1)
sys.exit

Fixed submission:
N, M = map(int, input().split())

ans = [0 for i in range(N)]
isTerms = [0 for i in range(N)]
jadge = True

for i in range(M):
    s, c = map(int, input().split())
    if( ans[s-1] != c and isTerms[s-1] != 0):
        jadge = False
    elif( s == 1 and c == 0):
        jadge = False
    else:
        ans[s-1] = c
        isTerms[s-1] = 1

if( N != 1 and ans[0] == 0 and jadge):
    ans[0] = 1

if( N == 1 and ans[0] == 0):
    jadge = True

if jadge:
    if(N==1):
        print(ans[0])
    else:
        for i in range(N-1):
            print(ans[i] ,end = "")
        print(ans[i+1])
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):

N, M = map(int, input().split())

C = []
S = []

for i in range(M):
    c, s = map(int, input().split())
    C.append(c)
    S.append(s)

for x in range(1000):
    keta = 1
    nx = x//10
    d = [x%10]


    while(nx):
        keta += 1
        d.append(nx%10)
        nx = nx // 10
    d = list(reversed(d))

    isOk = True
    
    for i in range(M):
        if( d[C[i]-1] != S[i-1] ):
            isOk = False

    if isOk :
        num = "".join(map(str, d))
        print(num)
        return 0

print(-1)
return 0

Fixed submission:
N, M = map(int, input().split())

ans = [0 for i in range(N)]
isTerms = [0 for i in range(N)]
jadge = True

for i in range(M):
    s, c = map(int, input().split())
    if( ans[s-1] != c and isTerms[s-1] != 0):
        jadge = False
    elif( s == 1 and c == 0):
        jadge = False
    else:
        ans[s-1] = c
        isTerms[s-1] = 1

if( N != 1 and ans[0] == 0 and jadge):
    ans[0] = 1

if( N == 1 and ans[0] == 0):
    jadge = True

if jadge:
    if(N==1):
        print(ans[0])
    else:
        for i in range(N-1):
            print(ans[i] ,end = "")
        print(ans[i+1])
else:
    print(-1)