Buggy python submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()
line1 = lines.pop(0).split(' ')
#print(line1)
N = int(line1[0])
M = int(line1[1])

#print(N)
#print(M)

str = [0] * N
ans = []
flg = 0
flg2 = 0
for i in range(M):
  line = lines.pop(0).split(' ')
#  print(line)
  s = int(line[0])
  c = int(line[1])
#  print(s)
#  print(c)
  str[s-1] = c
#  print('str = ')
#  print(str)
  one = int(str[0])
  if N == 3:
    ret = one*100 + int(str[1])*10 + int(str[2])
    if int(str[1])>0:
      flg = 1
    if int(str[2])>0:
      flg2 = 1
  elif N == 2:
    ret = one*10 + int(str[1])
    if int(str[1]) > 0:
      flg = 1
  else:
    if one > 0:
      ret = one
  ans.append(ret)

#print(ans)

for obj in ans[:]:
  if (obj / (10**(N-1))) < 1:
    ans.remove(obj)
    
  if N == 2:
    if flg == 1:
      a = obj % 10
      if a == 0:
#        print('リムーブ')
        ans.remove(obj)

  elif N == 3:
    if flg == 1 and flg2 ==1:
#      print('リムーブ候補')
#      print(obj)
      if obj % 100 == 0:
#        print('リムーブ')
        ans.remove(obj)
      elif obj % 10 == 0:
#        print('リムーブ')
        ans.remove(obj)
    elif flg == 0 and flg2 ==1:
#      print('リムーブ候補')
#      print(obj)
      b = obj % 10
      print(b)
      if b == 0:
#        print('リムーブ')
        ans.remove(obj)

if not ans:
  print('-1')
else:
#  print(ans)
  print(min(ans))


Fixed submission:
import sys
import math
lines = sys.stdin.readlines()
line1 = lines.pop(0).split(' ')
#print(line1)
N = int(line1[0])
M = int(line1[1])
#print(N)
#print(M)

#初期化
str = [10] * N
#print(str)

for i in range(M):
  line = lines.pop(0).split(' ')
#  print(line)
  s = int(line[0])
  c = int(line[1])
#  print(s)
#  print(c)
#  print(str[s-1])
#  if str[s-1] > c:
  if str[s-1] == 10:
    str[s-1] = c
  elif(str[s-1] == c):
    #同じ値の場合は何もしない
    pass
  else:
    #既に何かしらの異なる値が入っている場合はエラー
    print('-1')
    sys.exit()

#print(str)
#str = [0 if i == 10 else i for i in str]
#print(str)
if N == 3:
  if str[0] == 10 and str[1] == 10:
    str[0] = 1
    str[1] = 0
  elif str[0] == 10 and str[1] != 10:
    str[0] = 1
  elif str[0] != 10 and str[1] == 10:
    str[1] = 0

  str[2] = 0 if str[2] == 10 else str[2]

  ret = (int(str[0])*100 + int(str[1])*10 + int(str[2])) if int(str[0]) > 0 else -1
elif N ==2:
  str[0] = 1 if str[0] == 10 else str[0]
  str[1] = 0 if str[1] == 10 else str[1]
  ret = (int(str[0])*10 + int(str[1])) if int(str[0]) > 0 else -1
elif N ==1:
  str[0] = 0 if str[0] == 10 else str[0]
  ret = int(str[0])

print(ret)

Buggy python submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()
line1 = lines.pop(0).split(' ')
#print(line1)
N = int(line1[0])
M = int(line1[1])

#print(N)
#print(M)

str = [0] * N
ans = []
flg = 0
for i in range(M):
  line = lines.pop(0).split(' ')
#  print(line)
  s = int(line[0])
  c = int(line[1])
#  print(s)
#  print(c)
  str[s-1] = c
  print('str = ')
  print(str)
  one = int(str[0])
  if N == 3:
    ret = one*100 + int(str[1])*10 + int(str[2])
    if int(str[1])>0 or int(str[2])>0:
      flg = 1
  elif N == 2:
    ret = one*10 + int(str[1])
    if int(str[1]) > 0:
      flg = 1
  else:
    if one > 0:
      ret = one
  ans.append(ret)

print(ans)
div = 1
if N == 3:
  div = 100
elif N == 2:
  div = 10

for obj in ans[:]:
  if (obj / (10**(N-1))) < 1:
    ans.remove(obj)
  elif flg == 1:
    print('リムーブ候補')
    print(obj)
    print(div)
    a = obj % div
    print(a)
    if a == 0:
      print('リムーブ')

if not ans:
  print('-1')
else:
  print(ans)
  print(min(ans))


Fixed submission:
import sys
import math
lines = sys.stdin.readlines()
line1 = lines.pop(0).split(' ')
#print(line1)
N = int(line1[0])
M = int(line1[1])
#print(N)
#print(M)

#初期化
str = [10] * N
#print(str)

for i in range(M):
  line = lines.pop(0).split(' ')
#  print(line)
  s = int(line[0])
  c = int(line[1])
#  print(s)
#  print(c)
#  print(str[s-1])
#  if str[s-1] > c:
  if str[s-1] == 10:
    str[s-1] = c
  elif(str[s-1] == c):
    #同じ値の場合は何もしない
    pass
  else:
    #既に何かしらの異なる値が入っている場合はエラー
    print('-1')
    sys.exit()

#print(str)
#str = [0 if i == 10 else i for i in str]
#print(str)
if N == 3:
  if str[0] == 10 and str[1] == 10:
    str[0] = 1
    str[1] = 0
  elif str[0] == 10 and str[1] != 10:
    str[0] = 1
  elif str[0] != 10 and str[1] == 10:
    str[1] = 0

  str[2] = 0 if str[2] == 10 else str[2]

  ret = (int(str[0])*100 + int(str[1])*10 + int(str[2])) if int(str[0]) > 0 else -1
elif N ==2:
  str[0] = 1 if str[0] == 10 else str[0]
  str[1] = 0 if str[1] == 10 else str[1]
  ret = (int(str[0])*10 + int(str[1])) if int(str[0]) > 0 else -1
elif N ==1:
  str[0] = 0 if str[0] == 10 else str[0]
  ret = int(str[0])

print(ret)

Buggy python submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()
line1 = lines.pop(0).split(' ')
#print(line1)
N = int(line1[0])
M = int(line1[1])

#print(N)
#print(M)

str = [0] * N

ans = []

a = 0
b = 0
c = 0

for i in range(M):
  line = lines.pop(0).split(' ')
#  print(line)
  s = int(line[0])
  c = int(line[1])
#  print(s)
#  print(c)
  str[s-1] = c
  if N == 3:
    ret = int(str[0])*100 + int(str[1])*10 + int(str[2])
  elif N == 2:
    ret = int(str[0])*10 + int(str[1])
  else:
    ret = int(str[0])
  
  ans.append(ret)
  
for obj in ans[:]:
  if (obj / (10**(N-1))) < 1:
    ans.remove(obj)

print(min(ans))


Fixed submission:
import sys
import math
lines = sys.stdin.readlines()
line1 = lines.pop(0).split(' ')
#print(line1)
N = int(line1[0])
M = int(line1[1])
#print(N)
#print(M)

#初期化
str = [10] * N
#print(str)

for i in range(M):
  line = lines.pop(0).split(' ')
#  print(line)
  s = int(line[0])
  c = int(line[1])
#  print(s)
#  print(c)
#  print(str[s-1])
#  if str[s-1] > c:
  if str[s-1] == 10:
    str[s-1] = c
  elif(str[s-1] == c):
    #同じ値の場合は何もしない
    pass
  else:
    #既に何かしらの異なる値が入っている場合はエラー
    print('-1')
    sys.exit()

#print(str)
#str = [0 if i == 10 else i for i in str]
#print(str)
if N == 3:
  if str[0] == 10 and str[1] == 10:
    str[0] = 1
    str[1] = 0
  elif str[0] == 10 and str[1] != 10:
    str[0] = 1
  elif str[0] != 10 and str[1] == 10:
    str[1] = 0

  str[2] = 0 if str[2] == 10 else str[2]

  ret = (int(str[0])*100 + int(str[1])*10 + int(str[2])) if int(str[0]) > 0 else -1
elif N ==2:
  str[0] = 1 if str[0] == 10 else str[0]
  str[1] = 0 if str[1] == 10 else str[1]
  ret = (int(str[0])*10 + int(str[1])) if int(str[0]) > 0 else -1
elif N ==1:
  str[0] = 0 if str[0] == 10 else str[0]
  ret = int(str[0])

print(ret)