Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]
change = [0 for i in range(N)]

ans = -1
for i in range(10 ** 3):
  flag = True
  for j in range(M):
    if str(i)[q[i][0] - 1] != q[i][1]:
      flag = False
      
  if flag:
    ans = i
    break
    
print(ans)

Fixed submission:
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]

ans = -1
if N == 1:
  s = 0
else:
  s = 10 ** (N - 1)
for i in range(s, 10 ** N + 1):

  flag = True
  for j in range(M):
    try:
      if str(i)[q[j][0] - 1] != str(q[j][1]):
        flag = False
    except:
      flag = False
      break
      
  if flag:
    ans = i
    break
    
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]
change = [0 for i in range(N)]

ans = list('0' * N)
for i in range(M):
  if change[q[i][0]-1] == 0:
  	ans[q[i][0] - 1] = q[i][1]
  	change[q[i][0]-1] = 1
  else:
    if ans[q[i][0] - 1] != q[i][1]:
      ans = -1
      break
      
res = ''
for i in range(len(ans)):
  res += str(ans[i])
  
if res[0] == '0':
  print(-1)
else:
  print(int(res))


Fixed submission:
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]

ans = -1
if N == 1:
  s = 0
else:
  s = 10 ** (N - 1)
for i in range(s, 10 ** N + 1):

  flag = True
  for j in range(M):
    try:
      if str(i)[q[j][0] - 1] != str(q[j][1]):
        flag = False
    except:
      flag = False
      break
      
  if flag:
    ans = i
    break
    
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]
change = [0 for i in range(N)]

ans = list('0' * N)
for i in range(M):
  if change[q[i][0]-1] == 0:
  	ans[q[i][0] - 1] = q[i][1]
    change[q[i][0]-1] = 1
  else:
    if ans[q[i][0] - 1] != q[i][1]:
      ans = -1
      break
      
try:
  print(int(ans))
except:
  print(-1)


Fixed submission:
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]

ans = -1
if N == 1:
  s = 0
else:
  s = 10 ** (N - 1)
for i in range(s, 10 ** N + 1):

  flag = True
  for j in range(M):
    try:
      if str(i)[q[j][0] - 1] != str(q[j][1]):
        flag = False
    except:
      flag = False
      break
      
  if flag:
    ans = i
    break
    
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]
change = [0 for i in range(N)]

ans = list('0' * N)
for i in range(M):
  if change[q[i][0]-1] == 0:    
  	ans[q[i][0] - 1] = q[i][1]
    change[q[i][0]-1] = 1
  else:
    if ans[q[i][0] - 1] != q[i][1]:
      ans = -1
      break
      
try:
  print(int(ans))
except:
  print(-1)


Fixed submission:
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]

ans = -1
if N == 1:
  s = 0
else:
  s = 10 ** (N - 1)
for i in range(s, 10 ** N + 1):

  flag = True
  for j in range(M):
    try:
      if str(i)[q[j][0] - 1] != str(q[j][1]):
        flag = False
    except:
      flag = False
      break
      
  if flag:
    ans = i
    break
    
print(ans)