Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]
for i in range(0, 10**N):
    if len(str(i))==N and all(str(i)[s-1] == c for s,c in sc)
    print(i)
else:
    print(-1)

Fixed submission:
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]
for i in range(10**N): #rangeで書けば小さい順に実行するのを利用
    if len(str(i))==N and all(str(i)[s-1]==str(c) for s,c in sc):
                    #iの桁数指定では、入力のsと一つずれることに注意  
                    #このif文では最小値である可能性のある数字がリスト中にあるかどうか確認
        print(i)
        break
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]
for i in range(0, 10**N):
    if len(str(i))==N and all(str(i)[s-1] == c for s,c in sc)
    print('Yes')
else:
    print('No')

Fixed submission:
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]
for i in range(10**N): #rangeで書けば小さい順に実行するのを利用
    if len(str(i))==N and all(str(i)[s-1]==str(c) for s,c in sc):
                    #iの桁数指定では、入力のsと一つずれることに注意  
                    #このif文では最小値である可能性のある数字がリスト中にあるかどうか確認
        print(i)
        break
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for i in range(M)]
a = 0
for i in range(M):
    if SC[i][0] != N or (SC[i][0] ==3 and SC[i][1]==0):
        a += 1

handred = 0
ten = 0
one = 0

for i in range(M):
    if S[i][0] == 3:
        handred = 9
    elif S[i][0] == 2:
        ten = 9
    elif S[i][0] == 1:
        one = 9

if a == M:
    print('-1')
else:
    for i in range(M):
        if S[i][0] == 3:
            if handred >= S[i][1]:
                handred = S[i][1]
        elif S[i][0] == 2:
            if ten >= S[i][1]:
                ten = S[i][1]
        elif S[i][0] == 1:
            if one >= S[i][1]:
                one = S[i][1]

if a != M and N == 3:
    print(str(handred) + str(ten) + str(one))
elif a != M and N == 2:
    print(str(ten) + str(one))
elif a != M and N==1:
    print(str(one))

Fixed submission:
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]
for i in range(10**N): #rangeで書けば小さい順に実行するのを利用
    if len(str(i))==N and all(str(i)[s-1]==str(c) for s,c in sc):
                    #iの桁数指定では、入力のsと一つずれることに注意  
                    #このif文では最小値である可能性のある数字がリスト中にあるかどうか確認
        print(i)
        break
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for i in range(M)]
a = 0
for i in range(M):
    if SC[i][0] != N or SC[i][0] == 0:
        a += 1

handred = 0
ten = 0
one = 0

for i in range(M):
    if S[i][0] == 3:
        handred = 9
    elif S[i][0] == 2
        ten = 9
    elif S[i][0] == 1:
        one = 9

if a == M:
    print('-1')
else:
    for i in range(M):
        if S[i][0] == 3:
            if handred >= S[i][1]:
                handred = S[i][1]
        elif S[i][0] == 2:
            if ten >= S[i][1]:
                ten = S[i][1]
        elif S[i][0] == 1:
            if one >= S[i][1]:
                one = S[i][1]

if a != M and N == 3:
    print(str(handred) + str(ten) + str(one))
elif a != M and N == 2:
    print(str(ten) + str(one))
elif a != M and N==1:
    print(str(one))

Fixed submission:
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]
for i in range(10**N): #rangeで書けば小さい順に実行するのを利用
    if len(str(i))==N and all(str(i)[s-1]==str(c) for s,c in sc):
                    #iの桁数指定では、入力のsと一つずれることに注意  
                    #このif文では最小値である可能性のある数字がリスト中にあるかどうか確認
        print(i)
        break
else:
    print(-1)