Buggy python submission (verdict: Runtime Error):
    N, M = list(map(int, input().split(' ')))
    r = [ None for i in range(N) ]
     
    illegal = False
    for i in range(M):
      s, c = list(map(int, input().split(' ')))
      if r[s-1] is not None and r[s-1] != c:
        illegal = True
        break
      r[s-1] = c
     
    v = -1
    if not illegal:
      for i in range(N):
        if r[i] is None:
          if i == 0 and N != 1:
            r[i] = 1
          else:
            r[i] = 0
      v = sum(r[i] * 10**i for i in range(N))
      if v < 10**(N-1) and not (N == 1 and v == 0):
        v = -1
     
    print(v)

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

illegal = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None and r[s-1] != c:
    illegal = True
    break
  r[s-1] = c

v = -1
if not illegal:
  for i in range(N):
    if r[i] is None:
      if i == 0 and N != 1:
        r[i] = 1
      else:
        r[i] = 0
  v = sum(r[i] * 10**(N-1-i) for i in range(N))
  if v < 10**(N-1) and not (N == 1 and v == 0):
    v = -1

print(v)

Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, input().split(' ')))
r = [ None for i in range(N) ]
duplicated = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None:
	duplicated = True
    break
  r[s-1] = c

v = -1
if not duplicated:
  for i in range(N):
    if r[i] is None:
      r[i] = 0
  v = sum(r[i] * 10**i for i in range(N))
  if v < 100:
    v = -1

print(v)


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

illegal = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None and r[s-1] != c:
    illegal = True
    break
  r[s-1] = c

v = -1
if not illegal:
  for i in range(N):
    if r[i] is None:
      if i == 0 and N != 1:
        r[i] = 1
      else:
        r[i] = 0
  v = sum(r[i] * 10**(N-1-i) for i in range(N))
  if v < 10**(N-1) and not (N == 1 and v == 0):
    v = -1

print(v)

Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, input().split(' ')))
r = [ None for i in range(N) ]
duplicated = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None:
	duplicated = True
    break
  r[s-1] = c

if not duplicated:
  for i in range(N):
    if r[i] is None:
      r[i] = 0
  v = sum(r[i] * 10**i for i in range(N))
  print(v)
else:
  print(-1)


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

illegal = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None and r[s-1] != c:
    illegal = True
    break
  r[s-1] = c

v = -1
if not illegal:
  for i in range(N):
    if r[i] is None:
      if i == 0 and N != 1:
        r[i] = 1
      else:
        r[i] = 0
  v = sum(r[i] * 10**(N-1-i) for i in range(N))
  if v < 10**(N-1) and not (N == 1 and v == 0):
    v = -1

print(v)

Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, input().split(' ')))
r = [ None for i in range(N) ]
duplicated = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None:
	duplicated = True
    break
  r[s-1] = c

if duplicated:
  for i in range(N):
    if r[i] is None:
      r[i] = 0
  v = sum(r[i] * 10**i for i in range(N))
  print(v)
else:
  print(-1)


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

illegal = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None and r[s-1] != c:
    illegal = True
    break
  r[s-1] = c

v = -1
if not illegal:
  for i in range(N):
    if r[i] is None:
      if i == 0 and N != 1:
        r[i] = 1
      else:
        r[i] = 0
  v = sum(r[i] * 10**(N-1-i) for i in range(N))
  if v < 10**(N-1) and not (N == 1 and v == 0):
    v = -1

print(v)