Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]
sc.sort()
pin = 0
if N == 1:
  tmp = sc[0][1]
  for i in range(M):
    if tmp != sc[i][1]:
      print(-1)
      pin = 1
      break
  if pin == 0:
    print(tmp)
else:
  pin = 0
  ans_lis = [0] * N
  tmp_s = sc[0][0]
  tmp_c = sc[0][1]
  for i in range(M):
    if sc[i][0] == 1 and sc[i][1] == 0:
      print(-1)
      pin = 1
      break
    if tmp_s == sc[i][0]:
      if tmp_c != sc[i][1]:
        print(-1)
        pin = 1
        break
    else:
      ans_lis[tmp_s -1] = tmp_c
      tmp_s = sc[i][0]
      tmp_c = sc[i][1]
  if pin == 0:
    ans_lis[tmp_s -1] = tmp_c
    if ans_lis[0] == 0:
      ans_lis[0] = 1
    lis = map(str, ans_lis)
    mojiretsu = ''
    for x in lis:
      mojiretsu += x
    print(mojiretsu)
      
      


Fixed submission:
N, M = map(int, input().split())
if M == 0:
  if N == 1:
    print(0)
  elif N==2:
    print(10)
  else:
    print(100)
else:
  sc = [list(map(int, input().split())) for i in range(M)]
  sc.sort()
  pin = 0
  if N == 1:
    tmp = sc[0][1]
    for i in range(M):
      if tmp != sc[i][1]:
        print(-1)
        pin = 1
        break
    if pin == 0:
      print(tmp)
  else:
    pin = 0
    ans_lis = [0] * N
    tmp_s = sc[0][0]
    tmp_c = sc[0][1]
    for i in range(M):
      if sc[i][0] == 1 and sc[i][1] == 0:
        print(-1)
        pin = 1
        break
      if tmp_s == sc[i][0]:
        if tmp_c != sc[i][1]:
          print(-1)
          pin = 1
          break
      else:
        ans_lis[tmp_s -1] = tmp_c
        tmp_s = sc[i][0]
        tmp_c = sc[i][1]
    if pin == 0:
      ans_lis[tmp_s -1] = tmp_c
      if ans_lis[0] == 0:
        ans_lis[0] = 1
      lis = map(str, ans_lis)
      mojiretsu = ''
      for x in lis:
         mojiretsu += x
      print(mojiretsu)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]
sc.sort()
if N == 1:
  tmp = sc[0][1]
  for i in range(M):
    if tmp != sc[i][1]:
      print(-1)
      break
  print(tmp)
else:
  pin = 0
  ans_lis = [0] * N
  tmp_s = sc[0][0]
  tmp_c = sc[0][1]
  for i in range(M):
    if sc[i][0] == 1 and sc[i][1] == 0:
      print(-1)
      pin = 1
      break
    if tmp_s == sc[i][0]:
      if tmp_c != sc[i][1]:
        print(-1)
        pin = 1
        break
    else:
      ans_lis[tmp_s -1] = tmp_c
      tmp_s = sc[i][0]
      tmp_c = sc[i][1]
  if pin == 0:
    ans_lis[tmp_s -1] = tmp_c
    if ans_lis[0] == 0:
      ans_lis[0] = 1
    lis = map(str, ans_lis)
    mojiretsu = ''
    for x in lis:
      mojiretsu += x
    print(mojiretsu)
      
      


Fixed submission:
N, M = map(int, input().split())
if M == 0:
  if N == 1:
    print(0)
  elif N==2:
    print(10)
  else:
    print(100)
else:
  sc = [list(map(int, input().split())) for i in range(M)]
  sc.sort()
  pin = 0
  if N == 1:
    tmp = sc[0][1]
    for i in range(M):
      if tmp != sc[i][1]:
        print(-1)
        pin = 1
        break
    if pin == 0:
      print(tmp)
  else:
    pin = 0
    ans_lis = [0] * N
    tmp_s = sc[0][0]
    tmp_c = sc[0][1]
    for i in range(M):
      if sc[i][0] == 1 and sc[i][1] == 0:
        print(-1)
        pin = 1
        break
      if tmp_s == sc[i][0]:
        if tmp_c != sc[i][1]:
          print(-1)
          pin = 1
          break
      else:
        ans_lis[tmp_s -1] = tmp_c
        tmp_s = sc[i][0]
        tmp_c = sc[i][1]
    if pin == 0:
      ans_lis[tmp_s -1] = tmp_c
      if ans_lis[0] == 0:
        ans_lis[0] = 1
      lis = map(str, ans_lis)
      mojiretsu = ''
      for x in lis:
         mojiretsu += x
      print(mojiretsu)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]
sc.sort()
if N == 1:
  tmp = sc[0][1]
  for i in range(M):
    if tmp != sc[i][1]:
      print(-1)
      break
    print(tmp)
else:
  ans_lis = [0] * N
  tmp_s = sc[0][0]
  tmp_c = sc[0][1]
  for i in range(M):
    if sc[i][0] == 1 and sc[i][1] == 0:
      print(-1)
      break
    if tmp_s == sc[i][0]:
      if tmp_c != sc[i][1]:
        print(-1)
        break
    else:
      ans_lis[tmp_s -1] = tmp_c
      tmp_s = sc[i][0]
      tmp_c = sc[i][1]
      if ans_lis[0] == 0:
        ans_lis[0] = 1
      lis = map(str, ans_lis)
      mojiretsu = ''
      for x in lis:
        mojiretsu += x
      print(mojiretsu)
      
      

Fixed submission:
N, M = map(int, input().split())
if M == 0:
  if N == 1:
    print(0)
  elif N==2:
    print(10)
  else:
    print(100)
else:
  sc = [list(map(int, input().split())) for i in range(M)]
  sc.sort()
  pin = 0
  if N == 1:
    tmp = sc[0][1]
    for i in range(M):
      if tmp != sc[i][1]:
        print(-1)
        pin = 1
        break
    if pin == 0:
      print(tmp)
  else:
    pin = 0
    ans_lis = [0] * N
    tmp_s = sc[0][0]
    tmp_c = sc[0][1]
    for i in range(M):
      if sc[i][0] == 1 and sc[i][1] == 0:
        print(-1)
        pin = 1
        break
      if tmp_s == sc[i][0]:
        if tmp_c != sc[i][1]:
          print(-1)
          pin = 1
          break
      else:
        ans_lis[tmp_s -1] = tmp_c
        tmp_s = sc[i][0]
        tmp_c = sc[i][1]
    if pin == 0:
      ans_lis[tmp_s -1] = tmp_c
      if ans_lis[0] == 0:
        ans_lis[0] = 1
      lis = map(str, ans_lis)
      mojiretsu = ''
      for x in lis:
         mojiretsu += x
      print(mojiretsu)