Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = [list(map(int, input().split())) for _ in range(M)]
ans = ["0"]*M

for i in range(M):
    for  j in range(M):
            if list[i] == [1, 0] and list[i] != list[j] :
                print(-1)
                exit() #答えが0以外で先頭の数字が0になる場合
            elif list[i][0] == list[j][0] and list[i][1] != list[j][1]:
                print(-1)
                exit() #ある桁の数字が異なる場合
            elif list[i] == [1, 0] and N != 1:
                print(-1)
                exit() #Nが1でないのに答えが0になる場合
            elif list[i][0] > N:
                print(-1)
                exit() #指定の桁数と入力が異なる場合

for i in range(M):
    for j in range(M):
        if list[i][0] == j+1 :
            ans[j] = str(list[i][1])

print(int("".join(ans)))


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): #n桁の数字の全パターン
  number =str(i)
  if len(number)==n and all([number[s-1]==str(c) for s,c in sc]):
      print(number) #all すべての要素がTrueならTrue
      exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = [list(map(int, input().split())) for _ in range(M)]
ans = ["0"]*M

for i in range(M):
    for  j in range(M):
            if list[i] == [1, 0] and list[i] != list[j] :
                print(-1)
                exit() #答えが0以外で先頭の数字が0になる場合
            elif list[i][0] == list[j][0] and list[i][1] != list[j][1]:
                print(-1)
                exit() #ある桁の数字が異なる場合
            elif list[i] == [1, 0] and N != 1:
                print(-1)
                exit() #Nが1でないのに答えが0になる場合
            elif list[i][0] > N:
                print(-1)
                exit() #指定の桁数よりも大きな桁の数が入力された場合
            

for i in range(M):
    for j in range(M):
        if list[i][0] == j+1 :
            ans[j] = str(list[i][1])

print(int("".join(ans)))


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): #n桁の数字の全パターン
  number =str(i)
  if len(number)==n and all([number[s-1]==str(c) for s,c in sc]):
      print(number) #all すべての要素がTrueならTrue
      exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = [list(map(int, input().split())) for _ in range(M)]
ans = ["0"]*M

for i in range(M):
    for  j in range(M):
            if list[i] == [1, 0] and list[i] != list[j] :
                print(-1)
                exit() #答えが0以外で先頭の数字が0になる場合 
            elif list[i][0] == list[j][0] and list[i][1] != list[j][1]:
                print(-1)
                exit() #ある桁の数字が異なる場合
            elif list[i] == [1, 0] and N != 1:
                print(-1)
                exit() #Nが1でないのに答えが0になる場合

for i in range(M):
    for j in range(M):
        if list[i][0] == j+1 :
            ans[j] = str(list[i][1])

print(int("".join(ans)))


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): #n桁の数字の全パターン
  number =str(i)
  if len(number)==n and all([number[s-1]==str(c) for s,c in sc]):
      print(number) #all すべての要素がTrueならTrue
      exit()
print(-1)