qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n, m = map(int, input().split())
res = ["n" for _ in range(n)]
for _ in range(m):
    s, c = map(int, input().split())
    idx = s - 1
    if res[idx] == "n" or res[idx] == c:
        res[idx] = c
    if res[idx] != "n" and res[idx] != c:
        res = -1
        break
if res == -1: print(res)
else:
    if res[0] == "n":
        res[0] = 1
    for i in range(1, n):
        if res[i] == "n": res[i] = 0
    print(int("".join([str(r) for r in res])))

Fixed code:
n, m = map(int, input().split())
res = ["n" for _ in range(n)]
con = False
for _ in range(m):
    s, c = map(int, input().split())
    idx = s - 1
    if res[idx] == "n" or res[idx] == c:
        res[idx] = c
    if res[idx] != "n" and res[idx] != c:
        con = True
        break
if con or (n > 1 and res[0] == 0): print(-1)
else:
    if res[0] == "n":
        if n == 1:
            res[0] = 0
        else:
            res[0] = 1
    for i in range(1, n):
        if res[i] == "n": res[i] = 0
    print(int("".join([str(r) for r in res])))
Buggy code:
# -*- coding: utf-8 -*-


def main():
    n, m = map(int, input().split())
    joken_list = [tuple(map(int, input().split())) for i in range(m)]

    init_num = 0
    if n != 1:
        init_num = (init_num * 10) ** (n - 1)

    limit_num = 10 ** n

    result = "-1"
    for i in range(init_num, limit_num):
        i_s = str(i)
        match = True
        for keta, value in joken_list:
            if i_s[keta - 1 : keta] != str(value):
                match = False
                break

        if match:
            result = i_s
            break

    print(result)

if __name__ == '__main__':
    main()


Fixed code:
# -*- coding: utf-8 -*-


def main():
    n, m = map(int, input().split())
    joken_list = [tuple(map(int, input().split())) for i in range(m)]

    init_num = 0
    if n > 1:
        init_num = 10 ** (n - 1)
    limit_num = 10 ** n

    result = -1
    for i in range(init_num, limit_num):
        match = True
        for keta, value in joken_list:
            if str(i)[keta - 1] != str(value):
                match = False
                break

        if match:
            result = i
            break

    print(result)


if __name__ == '__main__':
    main()
Buggy code:
N,M = map(int,input().split())

lst = [-1]*N
flag = False

for _ in range(M):
  s,c = map(int,input().split())
  if lst[s-1] > -1:
    flag = True
  elif s == 1 and c== 0:
    flag = True
  else:
    lst[s-1] = c
if flag:
  print("-1")
else:
  for i in range(N):
    if i == 0 & lst[i] == -1:
      lst[i] = 1
    elif lst[i] == -1:
      lst[i] = 0
  print("".join(map(str,lst)))
  
  

Fixed code:
N,M = map(int,input().split())
 
lst = [-1]*N
flag = False
 
for _ in range(M):
  s,c = map(int,input().split())
  if lst[s-1] != -1 and lst[s-1] != c:
    flag = True
  elif s == 1 and c == 0 and N != 1:
    flag = True
  else:
    lst[s-1] = c
 
    
if flag:
  print("-1")
elif N == 1 and (lst[0] == 0 or lst[0] == -1):
  print("0")
else:
  for i in range(N):
    if i == 0 and lst[i] == -1:
      lst[i] = 1
    elif lst[i] == -1:
      lst[i] = 0
  print("".join(map(str,lst)))
Buggy code:
N,M = map(int,input().split())
sl = []
cl = []
for i in range(M):
    s,c = map(int,input().split())
    s -= 1
    sl.append(s)
    cl.append(c)
for i in range(1000):
    digit = list(str(i))
    if len(digit) != N:
        continue
    flag = True

    for j in range(M):
        print(sl[j])
        print(digit[sl[j]])
        if int(digit[sl[j]]) != cl[j]:
            flag = False
    if flag:
        print(i)
        exit()
print(-1)

Fixed code:
N,M = map(int,input().split())
sl = []
cl = []
for i in range(M):
    s,c = map(int,input().split())
    s -= 1
    sl.append(s)
    cl.append(c)
for i in range(1000):
    digit = list(str(i))
    if len(digit) != N:
        continue
    flag = True

    for j in range(M):
        if int(digit[sl[j]]) != cl[j]:
            flag = False
    if flag:
        print(i)
        exit()
print(-1)
Buggy code:
import sys
def main():
    n, m = map(int, input().split())
    s = [tuple(map(int, input().split())) for _ in range(m)]
    s = set(s)
    len_s = len(s)
    if len_s != len(set([sc[0] for sc in s])):
        print(-1)
        sys.exit()
    if m == 0:
        print(0)
        sys.exit()
    r = -1

    for i in range(10**n):
        i_s = str(i)
        i_s = i_s.zfill(n)
        flag = True
        if n == 2 and i_s[0] == 0 and i_s[1] == 0:
            continue
        elif n == 3 and i_s[0] == 0:
            continue
        for sc in s:
            if i_s[sc[0]-1] != str(sc[1]):
                flag = False
        if flag:
            r = i
            break
    print(r)
main()

Fixed code:
import sys
def main():
    n, m = map(int, input().split())
    s = [tuple(map(int, input().split())) for _ in range(m)]
    s = set(s)
    len_s = len(s)
    if len_s != len(set([sc[0] for sc in s])):
        print(-1)
        sys.exit()
    if m == 0 and n == 1:
        print(0)
        sys.exit()

    r = -1
    for i in range(10**n):
        i_s = str(i)
        i_s = i_s.zfill(n)
        flag = True
        for sc in s:
            if i_s[sc[0]-1] != str(sc[1]):
                flag = False
                continue
        if n == 3 and i_s[0] == '0':
            flag = False
        elif n == 3 and i_s[0] == '0' and i_s[1] == '0':
            flag = False
        elif n == 2 and i_s[0] == '0':
            flag = False
        if flag:
            r = i
            break
    print(r)
main()
Buggy code:
n, m = map(int, input().split())
ans = ['t'] * n

for _ in range(m):
    s, c = map(int, input().split())
    if ans[s-1] =='t' or ans[s-1] == str(c):
        ans[s-1]= str(c)
    else:
        print(-1)
        exit(0)
ans = ''.join(ans).replace('t', str(0))
ans = int(ans)
l = str(ans)
if l != n:
    print(-1)
else:
    print(ans)
    

Fixed code:
n, m = map(int, input().split())
ans = ['t'] * n

for _ in range(m):
    s, c = map(int, input().split())
    if ans[s-1] =='t' or ans[s-1] == str(c):
        ans[s-1]= str(c)
    else:
        print(-1)
        exit(0)
if ans[0] == 't' and n >1:
    ans[0]=str(1)

ans = ''.join(ans).replace('t', str(0))
ans = int(ans)
l = str(ans)
if len(l) != n:
    print(-1)
else:
    print(ans)
Buggy code:
N, M = map(int, input().split())
rslt = [-1]*N
for m in range(M):
  s, c = map(int, input().split())
  if s == 1 and c == 0:
    print(-1)
    exit()
  elif s >= N:
    print(-1)
    exit()
  elif rslt[s-1] != -1 and rslt[s-1] != c:
    print(-1)
    exit()
  else:
    rslt[s-1] = c

if rslt[0] == -1:
  rslt[0] = 1
rslt = ['0' if i == -1 else str(i) for i in rslt]
if rslt == [1]:
  print(0)
else:
  print(''.join(rslt))

Fixed code:
N, M = map(int, input().split())
rslt = [-1]*N
for m in range(M):
  s, c = map(int, input().split())
  if s == 1 and c == 0 and N>1:
    print(-1)
    exit()
  elif s > N:
    print(-1)
    exit()
  elif rslt[s-1] != -1 and rslt[s-1] != c:
    print(-1)
    exit()
  else:
    rslt[s-1] = c

if N>1 and rslt[0] == -1:
  rslt[0] = 1
rslt = ['0' if i == -1 else str(i) for i in rslt]
print(''.join(rslt))
Buggy code:
n, m = map(int,input().split())
z = []
for i in range(n):
  z.append(-1)
for i in range(m):
  x1,y1=[int(i) for i in input().split()]
  if z[x1-1] != -1:
    if z[x1-1] != y1:
      print(-1)
      exit(0)
  z[x1-1] = y1
if z[0] == -1:
  z[0] = 1
for i in range(1,n):
  if z[i] == -1:
    z[i] = 0
for s in z:
  print(s, end ="")

Fixed code:
n, m = map(int,input().split())
z = []
for i in range(n):
  z.append(-1)
for i in range(m):
  x1,y1=[int(i) for i in input().split()]
  if z[x1-1] != -1:
    if z[x1-1] != y1:
      print(-1)
      exit(0)
  if x1 == 1:
    if y1 == 0:
      if n != 1:
        print(-1)
        exit(0)
  z[x1-1] = y1
if n != 1:
  if z[0] == -1:
    z[0] = 1
else:
  if z[0] == -1:
    z[0] = 0
for i in range(1,n):
  if z[i] == -1:
    z[i] = 0
for s in z:
  print(s, end ="")
Buggy code:
n,m = map(int,input().split())
s = []
c = []
for i in range(m):
    val1,val2 = map(int,input().split())
    s.append(val1)
    c.append(val2)

for i in range(1000):
    if len(str(i)) == n:
        flg = True
        for j in range(m):
            if int(str(i)[j-1]) != c[j]:
                    flg = False
        if flg:
            print(i)
            break
if not flg:
    print(-1)

Fixed code:
n,m = map(int,input().split())
s = []
c = []
for i in range(m):
    val1,val2 = map(int,input().split())
    s.append(val1)
    c.append(val2)

for i in range(1000):
    if len(str(i)) == n:
        flg = True
        for j in range(m):
            if int(str(i)[s[j] - 1]) != c[j]:
                    flg = False
        if flg:
            print(i)
            break
if not flg:
    print(-1)
Buggy code:
line = input().split()
N, M = int(line[0]), int(line[1]) 

if M == 0:
  return 10**N

conds = []
for i in range(M):
  line = input().split()
  conds.append((int(line[0]),int(line[1])))
 
NUM = [-1] * N
 
isOK = True
for curCon in conds:
  s = curCon[0]
  dig = curCon[1]
  
  if NUM[s-1] == -1:
    NUM[s-1] = dig
  elif NUM[s-1] > dig:
    NUM[s-1] = dig
 
if N > 1:
  if NUM[0] == -1 or NUM[0] == 0:
    isOK = False
 
if isOK != True:
  print(-1)
else:
  for i in range(N):
    if NUM[i] == -1:
      NUM[i] = 0
  numChar = ""
  for iNum in NUM:
    numChar += str(iNum)
  print(int(numChar))

Fixed code:
line = input().split()
N, M = int(line[0]), int(line[1]) 

if M == 0:
  if N == 1:
    print(0)
  else:
    print(10**(N-1))
  quit()

conds = []
for i in range(M):
  line = input().split()
  conds.append((int(line[0]),int(line[1])))
 
NUM = [-1] * N
 
isOK = True
for curCon in conds:
  s = curCon[0]
  dig = curCon[1]
  
  if NUM[s-1] == -1:
    NUM[s-1] = dig
  elif NUM[s-1] != dig:
    isOK = False
 
if N > 1:
  if NUM[0] == 0:
    isOK = False
 
if isOK != True:
  print(-1)
  quit()
else:
  if NUM[0] == -1:
    NUM[0]=1
    
  for i in range(N):
    if NUM[i] == -1:
      NUM[i] = 0
  numChar = ""
  for iNum in NUM:
    numChar += str(iNum)
  print(int(numChar))
Buggy code:
n, m = list(map(int, input().split()))

d = [10] * n
r = 0

for i in range(m):
  s, c = list(map(int, input().split()))
  if d[s-1]>c:
    d[s-1]=c

if n==1:
  if d[0]==10:
    d[0] = 0
if n==2:
  if d[0]==10:
    d[0] = 1
  if d[1]==10:
    d[1] = 0
if n==3:
  if d[0]==10:
    d[0] = 1
  if d[1]==10:
    d[1] = 0
  if d[2]==10:
    d[2] = 0
        
if (r==-1):
  print(r)
else:
  dd = int(''.join(map(str, d)))
  if len(str(dd))==n:
    print(dd)
  else:
    print(-1)


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

d = [10] * n
r = 0

for i in range(m):
  s, c = list(map(int, input().split()))
  if d[s-1]>=c:
    if d[s-1]!=10 and d[s-1]!=c:
      print(-1)
      exit()
    d[s-1]=c
  else:
    print(-1)
    exit()

if n==1:
  if d[0]==10:
    d[0] = 0
if n==2:
  if d[0]==10:
    d[0] = 1
  if d[1]==10:
    d[1] = 0
if n==3:
  if d[0]==10:
    d[0] = 1
  if d[1]==10:
    d[1] = 0
  if d[2]==10:
    d[2] = 0
        
if (r==-1):
  print(r)
else:
  dd = int(''.join(map(str, d)))
  if len(str(dd))==n:
    print(dd)
  else:
    print(-1)
Buggy code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split())

X = [-1 for i in range(N)]
flg = 0

for i in range(M):
  s,c = map(int, input().split())
  s -= 1
  if s==0 and c==0:
    print(-1)
    flg = 1
    break
  if X[s]==-1:
    X[s] = c
  elif X[s]!=c:
    print(-1)
    flg = 1
    break

if flg==0:
  for i in range(N):
    print(9, end='') if X[i]==-1 else print(X[i], end='')

Fixed code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split())

X = [-1 for i in range(N)]
flg = 0

for i in range(M):
  s,c = map(int, input().split())
  s -= 1
  if N!=1 and s==0 and c==0:
    print(-1)
    flg = 1
    break
  if X[s]==-1:
    X[s] = c
  elif X[s]!=c:
    print(-1)
    flg = 1
    break

if flg==0:
  if N==1:
    print(0, end='') if X[0]==-1 else print(X[0], end='')
  else:
    for i in range(N):
      print(max(0,1-i), end='') if X[i]==-1 else print(X[i], end='')
Buggy code:
n,m = map(int,input().split())
a = [-1 for i in range(n)]
ans = True
for i in range(m):
  s,c = map(int,input().split())
  s -= 1
  if (n != 1 and s == 0 and c == 0) or (a[s] != -1 and a[s] != c):
    ans = False
    print(-1)
    break
  else:
    a[s] = c
if ans:
  for i in range(n):
    if a[i] == -1:
      a[i] = 1
    a[i] = str(a[i])
  print("".join(a))

Fixed code:
n,m = map(int,input().split())
a = [-1 for i in range(n)]
ans = True
for i in range(m):
  s,c = map(int,input().split())
  s -= 1
  if (n != 1 and s == 0 and c == 0) or (a[s] != -1 and a[s] != c):
    ans = False
    print(-1)
    break
  else:
    a[s] = c
if ans:
  for i in range(n):
    if a[i] == -1 and (n == 1 or (n != 1 and i != 0)):
      a[i] = 0
    elif a[i] == -1:
      a[i] = 1
    a[i] = str(a[i])
  print("".join(a))
Buggy code:
n,m = map(int,input().split())
done = [0]*n
ans = [0]*n
for i in range(m):
  s,c = map(int,input().split())
  if done[s-1] != 0 and ans[s-1] != c:
    print(-1)
    exit()
  elif s == n and c == 0:
    print(-1)
    exit()
  else:
    done[s-1] = 1
    ans[s-1] = c
ans_f = str()
for j in ans:
  ans_f += str(j)
if n>1 and ans_f[0] == "0":
  print("1"+ans_f[1::])
else:
  print(ans_f)

Fixed code:
n,m = map(int,input().split())
done = [0]*n
ans = [0]*n
for i in range(m):
  s,c = map(int,input().split())
  if done[s-1] != 0 and ans[s-1] != c:
    print(-1)
    exit()
  elif n != 1 and s == 1 and c == 0:
    print(-1)
    exit()
  else:
    done[s-1] = 1
    ans[s-1] = c
ans_f = str()
for j in ans:
  ans_f += str(j)
if n>1 and ans_f[0] == "0":
  print("1"+ans_f[1::])
else:
  print(ans_f)
Buggy code:
n, m = map(int, input().split())
ans = [-1]*n

if n = 1 and m = 0:
    print(0)
    exit()

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

    if s == 1 and c == 0:
        print(-1)
        exit()
        
    if ans[s-1] == -1 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print(-1)
        exit()

if ans[0] == -1:
    ans[0] = 1

for i in range(n):
    if ans[i] == -1:
        ans[i] = 0

print(*ans, sep="")

Fixed code:
n, m = map(int, input().split())
ans = [-1]*n

for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and n != 1:
        print(-1)
        exit()
    if ans[s-1] == -1 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print(-1)
        exit()

if ans[0] == -1 and n != 1:
    ans[0] = 1

for i in range(n):
    if ans[i] == -1:
        ans[i] = 0

print(*ans, sep="")
Buggy code:
n, m = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(m)]

ans = '1'
if m == 1:
    ans = '0'
for i in range(n-1):
    ans += '0'

while len(ans) == n:
    if all([ans[s-1] == str(c) for s, c in sc]):
        print(int(ans))
        exit()
    ans = str(int(ans)+1)
print(-1)

Fixed code:
n, m = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(m)]

ans = '1'
if n == 1:
    ans = '0'
for i in range(n-1):
    ans += '0'

while len(ans) == n:
    if all([ans[s-1] == str(c) for s, c in sc]):
        print(ans)
        exit()
    ans = str(int(ans)+1)
print(-1)
Buggy code:
n, m = map(int, input().split())
x = [-1] * n
for _ in range(m):
    s, c = map(int, input().split())
    s -= 1
    if x[s] != -1 and x[s] != c or n == 1 and s == 0 and c == 0:
        print(-1)
        quit()
    x[s] = c
if x[0] == -1:
    x[0] = 1
for i in range(1, n):
    if x[i] == -1:
        x[i] = 0
print(''.join(map(str, x)))

Fixed code:
n, m = map(int, input().split())
x = [-1] * n
for _ in range(m):
    s, c = map(int, input().split())
    s -= 1
    if x[s] != -1 and x[s] != c:
        print(-1)
        quit()
    x[s] = c
if n > 1 and x[0] == 0:
    print(-1)
    quit()

if x[0] == -1:
    x[0] = 1 if n > 1 else 0
for i in range(1, n):
    if x[i] == -1:
        x[i] = 0
print(''.join(map(str, x)))
Buggy code:
n, m = map(int,input().split())
lst = []
for _ in range(m):
    lst.append(list(map(int,input().split())))

number = [[] for _ in range(n)]
for v in lst:
    keta,num = v[0]-1,v[1]
    if not number[keta]:
        number[keta] = num
    else:
        if number[keta] != num:
            print(-1)
            exit()
if n == 1:
    if number[0] == 0:
        print(-1)
        exit()

    if not number[0]:
        number[0] = [0]
else:
    if not number[0]:
        number[0] = [1]

for i in range(m):
    if not number[i]:
        number[i] = 0

print(''.join([str(i) for i in number]))

Fixed code:
n, m = map(int,input().split())
lst = []
for _ in range(m):
    lst.append(list(map(int,input().split())))

number = [[] for _ in range(n)]
for v in lst:
    keta,num = v[0]-1,v[1]
    if number[keta] == []:
        number[keta] = num

    if number[keta] != num:
        print(-1)
        exit()

if n == 1:
    if not number[0]:
        print(0)
    else:
        print(''.join([str(i) for i in number]))
elif n == 2:
    if number[0] == 0:
        print(-1)
        exit()
    else:
        if not number[0]:
            number[0] = 1
        if not number[1]:
            number[1] = 0
        print(''.join([str(i) for i in number]))
else:
    if number[0] == 0:
        print(-1)
        exit()
    else:
        if not number[0]:
            number[0] = 1
        if not number[1]:
            number[1] = 0
        if not number[2]:
            number[2] = 0
        print(''.join([str(i) for i in number]))
Buggy code:
n, m = map(int, input().split())
ctr = [-1 for _ in range(n)]
flag = True
for i in range(m):
  p, q = map(int, input().split())
  p -= 1
  if ctr[p] == -1:
    ctr[p] = q
  else:
    flag = False
    break

flag = False if ctr[0] = 0

if flag:
  for i in ctr:
    print(1 if i == -1 else i, end="")
else:
  print(-1)

Fixed code:
n, m = map(int, input().split())
ctr = [-1 for _ in range(n)]
flag = True
for i in range(m):
  p, q = map(int, input().split())
  p -= 1
  if ctr[p] == -1:
    ctr[p] = q
  else:
    if(ctr[p] != q):
      flag = False
      break

if ctr[0] == 0 and n > 1:
  flag = False

if ctr[0] == -1:
  ctr[0] = 0 if n == 1 else 1
if flag:
  for i in ctr:
    print(0 if i == -1 else i, end="")
else:
  print(-1)
Buggy code:
dig, cnt = map(int, input().split())
ans = [-1]*dig
 
for i in range(cnt):
  place, num = map(int, input().split())
  place -= 1
  if ans[place] != -1:
    if ans[place] != num:
      print('-1')
      exit()
  elif place == 0 and num == 0:
    print('-1')
    exit()
  else:
    ans[place] = num
    
for i in range(cnt):
  if ans[i] == -1:
    if i == 0　and dig > 1:
      ans[i] = 1
    elif ans[i] == -1:
      ans[i] = 0
  print(ans[i], end="")

Fixed code:
dig, cnt = map(int, input().split())
ans = [-1]*dig
 
for i in range(cnt):
  place, num = map(int, input().split())
  place -= 1
  if ans[place] != -1:
    if ans[place] != num:
      
      print(-1)
      exit()
  elif place == 0 and num == 0 and dig > 1:
    print(-1)
    exit()
  else:
    ans[place] = num
    
for i in range(dig):
  if ans[i] == -1:
    if dig > 1 and i == 0:
      ans[i] = 1
    else:
      ans[i] = 0
  print(ans[i], end="")
Buggy code:
n, m = map(int, input().split())
num_list = ['X'] * n

def ans():
    return 0 if n == 1 and m == 0
    for i in range(m):
        set = list(map(str, input().split()))
        if set[0] == '1' and set[1] == '0' and n != 1:
            return -1
        else:
            if num_list[int(set[0]) - 1] == 'X':
                num_list[int(set[0]) - 1] = set[1]
            elif num_list[int(set[0]) - 1] == set[1]:
                continue
            else:
                return -1

    for i in range(n):
        if num_list[i] == 'X':
            num_list[i] = '1' if i == 0 else '0'

    return ''.join(num_list)

print(ans())


Fixed code:
n, m = map(int, input().split())
num_list = ['X'] * n

def ans():
    if n == 1 and m == 0:
        return 0
    for i in range(m):
        set = list(map(str, input().split()))
        if set[0] == '1' and set[1] == '0' and n != 1:
            return -1
        else:
            if num_list[int(set[0]) - 1] == 'X':
                num_list[int(set[0]) - 1] = set[1]
            elif num_list[int(set[0]) - 1] == set[1]:
                continue
            else:
                return -1


    if num_list[0] == 'X':
        num_list[0] = '1'

    for i in range(1, n):
        if num_list[i] == 'X':
            num_list[i] = '0'

    return ''.join(num_list)

print(ans())
Buggy code:
n,m = list(map(int,input().split()))
ans = ''
l = ['a']*n
for i in range(m):
    s,c = list(map(int,input().split()))
    if l[s-1] != 'a' and l[s-1] != str(c):
        ans = str(-1)
    else:
        l[s-1] = str(c)
if l[0] == 0:
    ans = str(-1)
if l[0] == 'a':
    l[0] = str(1)
if n >=2:
    if l[1] == 'a':
        l[1] = str(0)
if n >=3:
    if l[2] == 'a':
        l[2] = str(0)
if ans != '-1':
    ans = ''
    for j in range(n):
        ans += l[j]
       
print(int(ans))

Fixed code:
n,m = list(map(int,input().split()))
ans = ''
l = ['a']*n
for i in range(m):
    s,c = list(map(int,input().split()))
    if l[s-1] != 'a' and l[s-1] != str(c):
        ans = str(-1)
    else:
        l[s-1] = str(c)
if n != 1 and l[0] == str(0):
    ans = str(-1)
if n != 1 and l[0] == 'a':
    l[0] = str(1)
if n == 1 and l[0] == 'a':
    l[0] = '0'
if n >=2:
    if l[1] == 'a':
        l[1] = str(0)
if n >=3:
    if l[2] == 'a':
        l[2] = str(0)
if ans != '-1':
    ans = ''
    for j in range(n):
        ans += l[j]
       
print(int(ans))
Buggy code:
n,m = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]

count = float('inf')
if n == 3:
    for i in range(100, 1000):
        a = str(i)
        if all(int(a[s[j][0]-1]) == int(s[j][1]) for j in range(m)):
            if i < count:
                 count = i
elif n == 2:
    for i in range(10, 100):
        a = str(i)
        if all(int(a[s[j][0]-1]) == int(s[j][1]) for j in range(m)):
            if i < count:
                count = i
elif n == 1:
    for i in range(0, 10):
        a = str(i)
        if all(int(a[s[j][0]-1]) == int(s[j][1]) for j in range(m)):
            if i < count:
                count = i

if count == float('inf'):
    print(-1)
else:
    print(

Fixed code:
n,m = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]

count = float('inf')
if n == 3:
    for i in range(100, 1000):
        a = str(i)
        if all(int(a[s[j][0]-1]) == int(s[j][1]) for j in range(m)):
            if i < count:
                 count = i
elif n == 2:
    for i in range(10, 100):
        a = str(i)
        if all(int(a[s[j][0]-1]) == int(s[j][1]) for j in range(m)):
            if i < count:
                count = i
elif n == 1:
    for i in range(0, 10):
        a = str(i)
        if all(int(a[s[j][0]-1]) == int(s[j][1]) for j in range(m)):
            if i < count:
                count = i

if count == float('inf'):
    print(-1)
else:
    print(count)
Buggy code:
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
a=[-1]*n
ans=1
for i in range(len(sc)):
  if a[sc[i][0]-1]==-1:
    a[sc[i][0]-1]=sc[i][1]
  else:
    if a[sc[i][0]-1]!=sc[i][1]:
      ans=0
      break
ll=""
for j in range(n):
  if a[j]==-1:
    a[j]=0
  ll+=str(a[j])
if ans==0:
  print(-1)
else:
  if n!=len(str(int(ll))):
    print(-1)
    print(1)
  else:
    print(int(ll))

Fixed code:
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
a=[-1]*n
ans=1
for i in range(m):
  if a[sc[i][0]-1]==-1:
    a[sc[i][0]-1]=sc[i][1]
  else:
    if a[sc[i][0]-1]!=sc[i][1]:
      ans=0
      break
if a[0]==0 and n>=2:
  ans=0
ll=""
for j in range(n):
  if a[j]==-1:
    a[j]=0
  ll+=str(a[j])
  
if ans==0:
  print(-1)
else:
  if n!=len(str(int(ll))):
    print(int(ll)+10**(n-1))
  else:
    print(int(ll))