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())
if max(s) > n:
  print("-1")
  exit()
k1 = [100, 10, 1]
an =[]
zeros =[]
for i in range(m):
  if c[i] == 0:
    zeros.append(s[i])
  an.append(c[i] * k1[s[i] - 1])

for i in range(m):
  for j in range(m):
    if s[i] == s[j]:
      if c[i] != c[j]:
        print("-1")
        exit()
if len(sum(an)) != n:
  print("-1")
  exit()
if 10 ** max(zeros) > sum(an):
  print("-1")
  exit()
for i in range(m):
  if an.count(an[i]) != 1:
    an[i] = 0
if sum(an) == 0:
  print("-1")
  exit()
print(sum(an))

Fixed submission:
N, M = map(int,input().split())
sc = []
for _ in range(M):
    s, c = input().split()
    s = int(s)
    if s > N:
        print('-1')
        exit()
    sc.append([s, c])
 
ans = -1
if N == 1:
    start = 0
else:
    start = 10 ** (N - 1)
for i in range(start, 10 ** N):
    str_num = str(i)
    for s, c in sc:
        if str_num[s - 1] != c:
            break
    else:
        ans = i
        break
print(ans)

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())
if max(s) > n:
  print("-1")
  exit()
k1 = [100, 10, 1]
an =[]
zeros =[]
for i in range(m):
  if c[i] == 0:
    zeros.append(s[i])
  an.append(c[i] * k1[s[i] - 1])

for i in range(m):
  for j in range(m):
    if s[i] == s[j]:
      if c[i] != c[j]:
        print("-1")
        exit()
        
if 10 ** max(zeros) > sum(an):
  print("-1")
  exit()
for i in range(m):
  if an.count(an[i]) != 1:
    an[i] = 0
if sum(an) == 0:
  print("-1")
  exit()
print(sum(an))

Fixed submission:
N, M = map(int,input().split())
sc = []
for _ in range(M):
    s, c = input().split()
    s = int(s)
    if s > N:
        print('-1')
        exit()
    sc.append([s, c])
 
ans = -1
if N == 1:
    start = 0
else:
    start = 10 ** (N - 1)
for i in range(start, 10 ** N):
    str_num = str(i)
    for s, c in sc:
        if str_num[s - 1] != c:
            break
    else:
        ans = i
        break
print(ans)

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())

k1 = [100, 10, 1]
an =[]
zeros =[]
for i in range(m):
  if c[i] == 0:
    zeros.append(s[i])
  an.append(c[i] * k1[s[i] - 1])

for i in range(m):
  for j in range(m):
    if s[i] == s[j]:
      if c[i] != c[j]:
        print("-1")
        exit()
        
if 10 ** max(zeros) > sum(an):
  print("-1")
  exit()
for i in range(m):
  if an.count(an[i]) != 1:
    an[i] = 0
if sum(an) == 0:
  print("-1")
  exit()
print(sum(an))

Fixed submission:
N, M = map(int,input().split())
sc = []
for _ in range(M):
    s, c = input().split()
    s = int(s)
    if s > N:
        print('-1')
        exit()
    sc.append([s, c])
 
ans = -1
if N == 1:
    start = 0
else:
    start = 10 ** (N - 1)
for i in range(start, 10 ** N):
    str_num = str(i)
    for s, c in sc:
        if str_num[s - 1] != c:
            break
    else:
        ans = i
        break
print(ans)

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())

k1 = [100, 10, 1]
an =[]
for i in range(m):
  an.append(c[i] * k1[s[i] - 1])
  print(c[s[i] - 1] * k1[s[i] - 1])
print(an)

for i in range(m):
  for j in range(m):
    if s[i] == s[j]:
      if c[i] != c[j]:
        print("-1")
        exit()
        
for i in range(m):
  if an.count(an[i]) != 1:
    an[i] = 0
if sum(an) == 0:
  print("-1")
  exit()
print(sum(an))

Fixed submission:
N, M = map(int,input().split())
sc = []
for _ in range(M):
    s, c = input().split()
    s = int(s)
    if s > N:
        print('-1')
        exit()
    sc.append([s, c])
 
ans = -1
if N == 1:
    start = 0
else:
    start = 10 ** (N - 1)
for i in range(start, 10 ** N):
    str_num = str(i)
    for s, c in sc:
        if str_num[s - 1] != c:
            break
    else:
        ans = i
        break
print(ans)

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())

z = [0]*m
r = [0]*m
for i in range(m):
  r[s[i] - 1] = c[i]
  if s.count(s[i]) > 1:
    z[i] = i
if m > 1:
  if c[z[0]] != c[z[1]]:
    print(-1)
    exit()
if r[0] == 0 and n != 1:
  print(-1)
  exit()

if m >= 3:
  ans = r[0]*100 + r[1]*10 + r[2]*1
elif m == 2:
  ans = r[0]*10 + r[1]*1
else:
  ans = r[0]
print(ans)


Fixed submission:
N, M = map(int,input().split())
sc = []
for _ in range(M):
    s, c = input().split()
    s = int(s)
    if s > N:
        print('-1')
        exit()
    sc.append([s, c])
 
ans = -1
if N == 1:
    start = 0
else:
    start = 10 ** (N - 1)
for i in range(start, 10 ** N):
    str_num = str(i)
    for s, c in sc:
        if str_num[s - 1] != c:
            break
    else:
        ans = i
        break
print(ans)

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())

z = [0]*m
r = [0]*m
for i in range(m):
  r[s[i] - 1] = c[i]
  if s.count(s[i]) > 1:
    z[i] = i

if c[z[0]] != c[z[1]]:
  print(-1)
  exit()

if m >= 3:
  ans = r[0]*100 + r[1]*10 + r[2]*1
elif m == 2:
  ans = r[0]*10 + r[1]*1
else:
  ans = r[0]
print(ans)


Fixed submission:
N, M = map(int,input().split())
sc = []
for _ in range(M):
    s, c = input().split()
    s = int(s)
    if s > N:
        print('-1')
        exit()
    sc.append([s, c])
 
ans = -1
if N == 1:
    start = 0
else:
    start = 10 ** (N - 1)
for i in range(start, 10 ** N):
    str_num = str(i)
    for s, c in sc:
        if str_num[s - 1] != c:
            break
    else:
        ans = i
        break
print(ans)

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())

r = [0]*3  
for i in range(3):
  r[s[i] - 1] = c[i]
 
ans = r[0]*100 + r[1]*10 + r[2]*1
print(ans)

Fixed submission:
N, M = map(int,input().split())
sc = []
for _ in range(M):
    s, c = input().split()
    s = int(s)
    if s > N:
        print('-1')
        exit()
    sc.append([s, c])
 
ans = -1
if N == 1:
    start = 0
else:
    start = 10 ** (N - 1)
for i in range(start, 10 ** N):
    str_num = str(i)
    for s, c in sc:
        if str_num[s - 1] != c:
            break
    else:
        ans = i
        break
print(ans)