Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
s = [0]*m
c = [0]*m
for i in range(m):
  s[i],c[i] = map(int,input().split())
ans = [0]*n
ans[0] = 1

flag = 0

if n == 1:
  for i in range(m-1):
    if c[0]!=c[i+1]:
      flag=-1
      break
  if flag == 0:
    print(c[0])
  else: 
    print(-1)
      
if n == 2:
  for i in range(m):
    ans[s[i]-1]=c[i]
  for i in range(m):
    if ans[s[i]-1]!=c[i]:
      flag=-1
      break
  if ans[0] == 0:
    print(-1)
  elif flag == 0:
    print(ans[0]*10+ans[1])
  else: 
    print(-1)

if n == 3:
  for i in range(m):
    ans[s[i]-1]=c[i]
  for i in range(m):
    if ans[s[i]-1]!=c[i]:
      flag=-1
      break
  if ans[0]==0:
    print(-1)
  elif flag == 0:
    print(ans[0]*100+ans[1]*10+ans[2])
  else: 
    print(-1)

Fixed submission:
n,m = map(int,input().split())

ans = [0]*n
ans[0] = 1

misnot = 0

if m == 0:
  misnot=1

s = [0]*m
c = [0]*m
for i in range(m):
  s[i],c[i] = map(int,input().split())

flag = 0
if misnot == 0:
  if n == 1:
    for i in range(m-1):
      if c[0]!=c[i+1]:
        flag=-1
        break
    if flag == 0:
      print(c[0])
    else: 
      print(-1)

  if n == 2:
    for i in range(m):
      ans[s[i]-1]=c[i]
    for i in range(m):
      if ans[s[i]-1]!=c[i]:
        flag=-1
        break
    if ans[0] == 0:
      print(-1)
    elif flag == 0:
      print(ans[0]*10+ans[1])
    else: 
      print(-1)

  if n == 3:
    for i in range(m):
      ans[s[i]-1]=c[i]
    for i in range(m):
      if ans[s[i]-1]!=c[i]:
        flag=-1
        break
    if ans[0]==0:
      print(-1)
    elif flag == 0:
      print(ans[0]*100+ans[1]*10+ans[2])
    else: 
      print(-1)
else:
  if n == 1:
    print(0)
  elif n == 2:
    print(10)
  elif n == 3:
    print(100)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
s = [0]*m
c = [0]*m
for i in range(m):
  s[i],c[i] = map(int,input().split())
ans = [0]*n

flag = 0

if n == 1:
  for i in range(m-1):
    if c[0]!=c[i+1]:
      flag=-1
      break
  if flag == 0:
    print(c[0])
  else: print(-1)
      
if n == 2:
  for i in range(m):
    ans[s[i]-1]=c[i]
  for i in range(m):
    if ans[s[i]-1]!=c[i]:
      flag=-1
      break
  if ans[0] == 0:
    print(-1)
  elif flag == 0:
    print(ans[0]*10+ans[1])
  else: print(-1)

if n == 3:
  for i in range(m):
    ans[s[i]-1]=c[i]
  for i in range(m):
    if ans[s[i]-1]!=c[i]:
      flag=-1
      break
  if ans[0]==0:
    print(-1)
  elif flag == 0:
    print(ans[0]*100+ans[1]*10+ans[2])
  else: print(-1)

Fixed submission:
n,m = map(int,input().split())

ans = [0]*n
ans[0] = 1

misnot = 0

if m == 0:
  misnot=1

s = [0]*m
c = [0]*m
for i in range(m):
  s[i],c[i] = map(int,input().split())

flag = 0
if misnot == 0:
  if n == 1:
    for i in range(m-1):
      if c[0]!=c[i+1]:
        flag=-1
        break
    if flag == 0:
      print(c[0])
    else: 
      print(-1)

  if n == 2:
    for i in range(m):
      ans[s[i]-1]=c[i]
    for i in range(m):
      if ans[s[i]-1]!=c[i]:
        flag=-1
        break
    if ans[0] == 0:
      print(-1)
    elif flag == 0:
      print(ans[0]*10+ans[1])
    else: 
      print(-1)

  if n == 3:
    for i in range(m):
      ans[s[i]-1]=c[i]
    for i in range(m):
      if ans[s[i]-1]!=c[i]:
        flag=-1
        break
    if ans[0]==0:
      print(-1)
    elif flag == 0:
      print(ans[0]*100+ans[1]*10+ans[2])
    else: 
      print(-1)
else:
  if n == 1:
    print(0)
  elif n == 2:
    print(10)
  elif n == 3:
    print(100)