Buggy python submission (verdict: Runtime Error):
import sys
 
n,m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
 
sc.sort()
ans = 0
d = 0
s = 0
 
if n != 1 and sc[0][0] == 1 and sc[0][1] == 0:
  print('-1')
  sys.exit()

if n != 1 and sc[0][0] != 1:
  ans += 10**(n-1)
 
for i in sc:
  if i[0] != d:
    d = i[0]
    s = i[1]
    ans += s * (10 ** (n-d))
  else:
    if i[1] != s:
      print('-1')
      sys.exit()
 
print(ans)

Fixed submission:
import sys

n,m = map(int, input().split())

num = ['-'] * n

for i in range (m):
  s,c = map(int, input().split())
  if num[s-1] != '-' and num[s-1] != c:
    print('-1')
    sys.exit()
  else:
    num[s-1] = c

if n > 1:
  if num[0] == 0:
    print('-1')
    sys.exit()
  elif num[0] == '-':
    num[0] = 1 
  
for i in range(n):
  if num[i] == '-':
    num[i] = '0'
  else:
    num[i] = str(num[i])

print(''.join(num))

Buggy python submission (verdict: Runtime Error):
import sys
 
n,m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
 
sc.sort()
ans = 0
d = 0
s = 0
 
if n != 1 and sc[0] == [1, 0]:
  print('-1')
  sys.exit()

if n != 1 and sc[0][0] != 1:
  ans += 10**(n-1)
 
for i in sc:
  if i[0] != d:
    d = i[0]
    s = i[1]
    ans += s * (10 ** (n-d))
  else:
    if i[1] != s:
      print('-1')
      sys.exit()
 
print(ans)

Fixed submission:
import sys

n,m = map(int, input().split())

num = ['-'] * n

for i in range (m):
  s,c = map(int, input().split())
  if num[s-1] != '-' and num[s-1] != c:
    print('-1')
    sys.exit()
  else:
    num[s-1] = c

if n > 1:
  if num[0] == 0:
    print('-1')
    sys.exit()
  elif num[0] == '-':
    num[0] = 1 
  
for i in range(n):
  if num[i] == '-':
    num[i] = '0'
  else:
    num[i] = str(num[i])

print(''.join(num))

Buggy python submission (verdict: Runtime Error):
import sys
 
n,m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
 
sc.sort()
ans = 0
d = 0
s = 0
 
if sc[0] == [1, 0]:
  print('-1')
  sys.exit()

if sc[0][0] != 1:
  ans += 10**(n-1)
 
for i in sc:
  if i[0] != d:
    d = i[0]
    s = i[1]
    ans += s * (10 ** (n-d))
  else:
    if i[1] != s:
      print('-1')
      sys.exit()
 
print(ans)

Fixed submission:
import sys

n,m = map(int, input().split())

num = ['-'] * n

for i in range (m):
  s,c = map(int, input().split())
  if num[s-1] != '-' and num[s-1] != c:
    print('-1')
    sys.exit()
  else:
    num[s-1] = c

if n > 1:
  if num[0] == 0:
    print('-1')
    sys.exit()
  elif num[0] == '-':
    num[0] = 1 
  
for i in range(n):
  if num[i] == '-':
    num[i] = '0'
  else:
    num[i] = str(num[i])

print(''.join(num))

Buggy python submission (verdict: Runtime Error):
import sys
 
n,m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
 
sc.sort()
ans = 0
d = 0
s = 0
 
if sc[0][1] == 0 and n != 1:
  print('-1')
  sys.exit()

if sc[0][0] != 1:
  ans += 10**(n-1)
 
for i in sc:
  if i[0] != d:
    d = i[0]
    s = i[1]
    ans += s * (10 ** (n-d))
  else:
    if i[1] != s:
      print('-1')
      sys.exit()
 
print(ans)

Fixed submission:
import sys

n,m = map(int, input().split())

num = ['-'] * n

for i in range (m):
  s,c = map(int, input().split())
  if num[s-1] != '-' and num[s-1] != c:
    print('-1')
    sys.exit()
  else:
    num[s-1] = c

if n > 1:
  if num[0] == 0:
    print('-1')
    sys.exit()
  elif num[0] == '-':
    num[0] = 1 
  
for i in range(n):
  if num[i] == '-':
    num[i] = '0'
  else:
    num[i] = str(num[i])

print(''.join(num))

Buggy python submission (verdict: Runtime Error):
import sys
 
n,m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
 
sc.sort()
ans = 0
d = 0
s = 0
 
if sc[0][1] == 0 and n != 1:
  print('-1')
  sys.exit()
 
for i in sc:
  if i[0] != d:
    d = i[0]
    s = i[1]
    ans += s * (10 ** (n-d))
  else:
    if i[1] != s:
      print('-1')
      sys.exit()
 
print(ans)

Fixed submission:
import sys

n,m = map(int, input().split())

num = ['-'] * n

for i in range (m):
  s,c = map(int, input().split())
  if num[s-1] != '-' and num[s-1] != c:
    print('-1')
    sys.exit()
  else:
    num[s-1] = c

if n > 1:
  if num[0] == 0:
    print('-1')
    sys.exit()
  elif num[0] == '-':
    num[0] = 1 
  
for i in range(n):
  if num[i] == '-':
    num[i] = '0'
  else:
    num[i] = str(num[i])

print(''.join(num))

Buggy python submission (verdict: Runtime Error):
import sys

n,m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]

sc.sort()
ans = 0
d = 0
s = 0

if sc[0][1] == 0 and len(sc) != 1:
  print('-1')
  sys.exit()

for i in sc:
  if i[0] != d:
    d = i[0]
    s = i[1]
    ans += s * (10 ** (n-d))
  else:
    if i[1] != s:
      print('-1')
      sys.exit()

print(ans)

Fixed submission:
import sys

n,m = map(int, input().split())

num = ['-'] * n

for i in range (m):
  s,c = map(int, input().split())
  if num[s-1] != '-' and num[s-1] != c:
    print('-1')
    sys.exit()
  else:
    num[s-1] = c

if n > 1:
  if num[0] == 0:
    print('-1')
    sys.exit()
  elif num[0] == '-':
    num[0] = 1 
  
for i in range(n):
  if num[i] == '-':
    num[i] = '0'
  else:
    num[i] = str(num[i])

print(''.join(num))

Buggy python submission (verdict: Runtime Error):
import sys

n,m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]

sc.sort()
ans = 0
d = 0
s = 0

if sc[0][1] == 0:
  print('-1')
  sys.exit()

for i in sc:
  if i[0] != d:
    d = i[0]
    s = i[1]
    ans += s * (10 ** (n-d))
  else:
    if i[1] != s:
      print('-1')
      sys.exit()

print(ans)

Fixed submission:
import sys

n,m = map(int, input().split())

num = ['-'] * n

for i in range (m):
  s,c = map(int, input().split())
  if num[s-1] != '-' and num[s-1] != c:
    print('-1')
    sys.exit()
  else:
    num[s-1] = c

if n > 1:
  if num[0] == 0:
    print('-1')
    sys.exit()
  elif num[0] == '-':
    num[0] = 1 
  
for i in range(n):
  if num[i] == '-':
    num[i] = '0'
  else:
    num[i] = str(num[i])

print(''.join(num))