qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N, M = map(int, input().split())

flag = 0
x = [1000] * N
for m in range(M):
  s, c = map(int, input().split())
  if (x[s-1] != -1) & (x[s-1] != c):
    if (s == 1) & (c == 0) & (N != 1):
      pass
    else:
      x[s-1] = x[s-1] if x[s-1] < c else c
  else:
    x[s-1] = c
print(x)
    
ans = 0
for n in range(N):
  if x[n] != 1000:
    ans += 10**(N-n-1) * x[n]
#print(ans)

if (N == 1) & (M > 0):
  print(ans)

elif (ans >= 10**(N-1)) & (flag == 0):
  print(ans)
else:
  print(-1)

Fixed code:
N, M = map(int, input().split())

flag = 0
x = [1000] * N
for m in range(M):
  s, c = map(int, input().split())
  if (x[s-1] != 1000) & (x[s-1] != c):
    #print("{} {}".format(s,c))
    flag = 1
    pass
    if (s == 1) & (c == 0) & (N != 1):
      pass
    else:
      x[s-1] = x[s-1] if x[s-1] < c else c
  else:
    x[s-1] = c
#print(x)
    
ans = 0
for n in range(N):
  if x[n] != 1000:
    ans += 10**(N-n-1) * x[n]
  elif n==0:
    ans += 10**(N-n-1) * 1
#print(ans)

if (N == 1) & (M == 0) & (flag == 0):
  print(0)
elif (N == 1) & (M > 0) & (flag == 0):
  print(ans)
elif (ans >= 10**(N-1)) & (flag == 0):
  print(ans)
else:
  print(-1)
Buggy code:
N,M = map(int,input().split())
sc = [[0,0]]*M
ans = [0]*N
f = True
ans = -1
for i in range(M):
    sc[i] = list(map(int,input().split()))

for i in range(1000):
    str_i = str(i)
    if (len(str_i) == N):
        f = True
        for j in range(M):
            f &= (str_i[sc[i][0]-1] == str(sc[i][1]))
        if (f):
            ans = i
            break

print(ans)

Fixed code:
N,M = map(int,input().split())
sc = [[0,0]]*M
ans = [0]*N
f = True
ans = -1
for i in range(M):
    sc[i] = list(map(int,input().split()))

for i in range(1000):
    str_i = list(str(i))
    if (len(str_i) == N):
        f = True
        for j in range(M):
            f &= (str_i[sc[j][0]-1] == str(sc[j][1]))
        if (f):
            ans = i
            break

print(ans)
Buggy code:
n,m=list(map(int,input().split()))
ans=[1]+[0]*(n-1)
check=0

for _ in range(m):
    s,c=list(map(int,input().split()))
    s-=1
    if s==0:
        if c==0:
            check+=1
            break
        elif ans[s]!=1:
            check+=1
            break
        else:
            ans[s]=c
    else:
        if ans[s]!=0:
            check+=1
            break
        else:
            ans[s]=c
if check>0:
  print(str(-1))
else:
  ans=list(map(str,ans))
  print("".join(ans))


Fixed code:
n,m=list(map(int,input().split()))
if n!=1:
    ans=[1]+[0]*(n-1)
    checks=[0]*n
    check=0

    for _ in range(m):
        s,c=list(map(int,input().split()))
        s-=1
        if s==0:
            if c==0:
                check+=1
                break
            elif checks[s]!=0 and ans[s]!=c:
                check+=1
                break
            else:
                checks[s]+=1
                ans[s]=c
        else:
            if checks[s]!=0 and ans[s]!=c:
                check+=1
                break
            else:
                checks[s]+=1
                ans[s]=c
else:
    ans=[0]
    checks=[0]
    check=0
    for _ in range(m):
        s,c=list(map(int,input().split()))
        s-=1
        if checks[s]!=0 and ans[s]!=c:
            check+=1
            break
        else:
            checks[s]+=1
            ans[s]=c

if check>0:
  print(str(-1))
else:
  ans=list(map(str,ans))
  print("".join(ans))
Buggy code:
n,m=map(int,input().split())
s=[list(map(int,input().split())) for i in range(m)]
def exit():
    import sys
    print(-1)
    sys.exit()
num=['']*n
for i in range(m):
    if s[i]==[1,0]:
        exit()
    if num[s[i][0]-1]!='':
        if num[s[i][0]-1]==s[i][1]:
            continue
        else:
            exit()
    else:
        num[s[i][0]-1]=s[i][1]
else:
    print(num)
    if num[0]!=0 and num[0]!='':
        for i in range(n):
            print(num[i] if num[i]!='' else 0, end='')
    else:
        print(-1)

Fixed code:
n,m=map(int,input().split())
def exit():
    import sys
    print(-1)
    sys.exit()
num=['']*n
for s,c in (map(int,input().split()) for i in range(m)):
    if n>1 and [s,c]==[1,0]:
        exit()
    if num[s-1]!='':
        if num[s-1]==c:
            continue
        else:
            exit()
    else:
        num[s-1]=c
else:
    if n==1:
        print(num[0] if num[0]!='' else 0, end='')
    else:
        print(num[0] if num[0]!='' else 1, end='')
    for i in range(1,n):
        print(num[i] if num[i]!='' else 0, end='')
Buggy code:
n,m=map(int, input().split())
l = [None]*n
msg=''
for _ in range(m):
    s, c = input().split()
    index = int(s)-1
    if l[index] is None:
        l[index] = c
    else:
        if l[index] == c:
            continue
        else:
            msg=-1
            break
l = list(map(lambda x: '0' if x in None else x, l))
if msg == -1:
    print(msg)
elif l[0] == '0' and len(l) >1:
    print(-1)
else:
    print(msg.join(l))


Fixed code:
n,m=map(int, input().split())
l = [None]*n
msg=''
for _ in range(m):
    s, c = input().split()
    index = int(s)-1
    if l[index] is None:
        l[index] = c
    else:
        if l[index] == c:
            continue
        else:
            msg=-1
            break
if l[0] is None and len(l) != 1:
    l[0]='1'
l = list(map(lambda x: '0' if x is None else x, l))
if msg == -1:
    print(msg)
elif l[0] == '0' and len(l) != 1:
    print(-1)
else:
    print(msg.join(l))
Buggy code:
N, M = [int(i) for i in input().split()]
sc = [[int(i) for i in input().split()] for _ in range(M)]
ans = ["0"]*N
f = [False]*N
for s, c in sc:
    s -= 1
    c = str(c)
    if f[s] and ans[s] != c:
        break
    f[s] = True
    ans[s] = c
else:
    if not(N != 1 and ans[0] == '0'):
        print(''.join(ans))
    else:
        ans[0] = '1'
        print(''.join(ans))
    exit()

print(-1)


Fixed code:
N, M = [int(i) for i in input().split()]
sc = [[int(i) for i in input().split()] for _ in range(M)]
ans = ["0"]*N
f = [False]*N
for s, c in sc:
    s -= 1
    c = str(c)
    if (f[s] and ans[s] != c)or(N > 1 and s == 0 and c == '0'):
        break
    f[s] = True
    ans[s] = c
else:
    if not(N != 1 and ans[0] == '0'):
        print(''.join(ans))
    else:
        ans[0] = '1'
        print(''.join(ans))
    exit()

print(-1)
Buggy code:
n,m=map(int,input().split())
jouken=[]
for x in range(m):
  jouken.append(list(map(int,input().split())))

for x in range(10**n):
  ans=0
  xx=str(x)
  if not len(xx)==n:
    continue
  for y in range(m):
    a=jouken[y][0]-1
    b=jouken[y][1]
    
    
    if not int(xx[a])==b:
      ans+=1
    
  if ans==0:
    print(x)
    break

if ans>1:
  print(-1)



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

for x in range(10**n):
  ans=0
  xx=str(x)
  if not len(xx)==n:
    continue
  for y in range(m):
    a=jouken[y][0]-1
    b=jouken[y][1]
    
    
    if not int(xx[a])==b:
      ans+=1
    
  if ans==0:
    print(x)
    break

if ans>=1:
  print(-1)
Buggy code:
N, M = map(int, input().split())
num = [None]*N
res = 0
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if n > 1 and s == 0 and c == 0:
        res = -1
        break    
    if num[s] == None:
        num[s] = c
    elif num[s] != c:
        res = -1
        break

print(res) if res == -1 else print(0) if M == 0 else print(*[e if e!=None else 0 if i != 0 else 1 for i, e in enumerate(num)], sep="")

Fixed code:
N, M = map(int, input().split())
num = [None]*N
res = 0
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if N > 1 and s == 0 and c == 0:
        res = -1
        break    
    if num[s] == None:
        num[s] = c
    elif num[s] != c:
        res = -1
        break

print(res) if res == -1 else print(*[e if e!=None else 0 if i != 0 or N == 1 else 1 for i, e in enumerate(num)], sep="")
Buggy code:
N,M = map(int, input().split())

sets = []
for i in range(M):
  s,c = input().split()
  sets.append((s,c))

start = 0
if N != 1:
  start = 10**(N-1)

for n in range(start,10**N):
  print(n)
  for s,c in sets:
    if str(n)[int(s)-1] == c:
      continue
    else:
      break
  else:
    print(n)
    break
else:
  print(-1)

Fixed code:
N,M = map(int, input().split())

sets = []
for i in range(M):
  s,c = input().split()
  sets.append((s,c))

start = 0
if N != 1:
  start = 10**(N-1)

for n in range(start,10**N):
  for s,c in sets:
    if str(n)[int(s)-1] == c:
      continue
    else:
      break
  else:
    print(n)
    break
else:
  print(-1)
Buggy code:
N, M = list(map(int, input().split()))
ans = [-1]*N

flag = True
for _ in range(M):
    s, c = list(map(int, input().split()))
    if s == 1 and c == 0:
        flag = False
        break
    
    if ans[s-1] == -1:
        ans[s-1] = c
    else:
        if ans[s-1] != c:
            flag = False
            break

if flag:
    print("".join(["3" if e == -1 else str(e) for e in ans]))
else:
    print(-1)


Fixed code:
N, M = list(map(int, input().split()))
ans = [-1]*N

flag = True

if N == 1:
    for _ in range(M):
        s, c = list(map(int, input().split()))
        if ans[s-1] == -1:
            ans[s-1] = c
        else:
            if ans[s-1] != c:
                flag = False
                break
    if flag:
        print(max(0, ans[0]))
    else:
        print(-1)

else:
    for _ in range(M):
        s, c = list(map(int, input().split()))
        if s == 1 and c == 0:
            flag = False
            break

        if ans[s-1] == -1:
            ans[s-1] = c
        else:
            if ans[s-1] != c:
                flag = False
                break

    if flag:
        ans[0] = max(1, ans[0])
        print("".join(["0" if e == -1 else str(e) for e in ans]))
    else:
        print(-1)
Buggy code:
N,M = map(int,input().split())

num = [-1 for _ in range(N)]

flag = False
for i in range(M):
    s,c = map(int,input().split())
    if num[s-1] == -1 or num[s-1] == c:
        num[s-1] = c
    else:
        break
else:
    flag = True

if flag==False or num[-1]==0:
    print(-1)
else:
    ans = 0
    if num[-1] == -1:
        num[-1] = 1
    for i in range(N):
        if num[i]!=-1:
            ans += num[i]*(10**(N-i-1))
    print(ans)

Fixed code:
N,M = map(int,input().split())

num = [-1 for _ in range(N)]

flag = False
for i in range(M):
    s,c = map(int,input().split())
    if num[s-1] == -1 or num[s-1] == c:
        num[s-1] = c
    else:
        break
else:
    flag = True

if flag==False or (num[0]==0 and N>1):
    print(-1)
else:
    ans = 0
    if num[0]==-1 and N>1:
        num[0] = 1
    for i in range(N):
        if num[i]!=-1:
            ans += num[i]*(10**(N-i-1))
    print(ans)
Buggy code:
N, M = map(int, input().split())
SC = [tuple(map(int, input().split())) for _ in range(M)]

for i in range(10**N):
    i = str(i)
    for s, c in SC:
        if len(i) < s:
            break
        if i[s - 1] != str(c):
            break
    else:
        print(i)
        exit()

print(-1)


Fixed code:
N, M = map(int, input().split())
SC = [tuple(map(int, input().split())) for _ in range(M)]

for i in range(10**N):
    i = str(i)
    if len(i) != N:
        continue
    for s, c in SC:
        if len(i) < s:
            break
        if i[s - 1] != str(c):
            break
    else:
        print(i)
        exit()

print(-1)
Buggy code:
n,m = map(int, input().split())

ans = [" "]*n
flag = 0

#print(ans)

for i in range(m):
    s, c = map(int, input().split())
    if (ans[s - 1] == " " or ans[s - 1] == c):
        ans[s - 1] = c
    else:
        flag = 1
        break


if (flag == 1):
    print(-1)
else:
    for i in range(n):
        if (ans[i] != " "):
            print(ans[i],end="")
        elif (i == 0):
            print(1,end="")
        else:
            print(0, end="")

    print()

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

ans = [" "]*n
flag = 0

#print(ans)

for i in range(m):
    s, c = map(int, input().split())
    if (ans[s - 1] == " " or ans[s - 1] == c):
        ans[s - 1] = c
    else:
        flag = 1
        break


if (flag == 1 or (ans[0] == 0 and n!=1)):
    print(-1)
else:
    for i in range(n):
        if (ans[i] != " "):
            print(ans[i],end="")
        elif (i == 0 and n != 1):
            print(1,end="")
        else:
            print(0, end="")

    print()
Buggy code:
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]

A = [-1] * N
ok= True
for s, c in SC:
    i = s-1
    if A[i] != -1 and A[i] != c:
        ok = False
        break
    A[i] = c
if N > 1 and A[0]==0:
    ok = False
if ok:
    for i in range(N):
        if A[i] == -1:
            if i == 0 && N != 1:
                A[i] = 1
            else:
                A[i] = 0
if ok:
    print(''.join(map(str, A)))
else:    
    print(-1)

Fixed code:
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]

A = [-1] * N
ok= True
for s, c in SC:
    i = s-1
    if A[i] != -1 and A[i] != c:
        ok = False
        break
    A[i] = c
if N > 1 and A[0]==0:
    ok = False
if ok:
    for i in range(N):
        if A[i] == -1:
            if i == 0 and N != 1:
                A[i] = 1
            else:
                A[i] = 0
if ok:
    print(''.join(map(str, A)))
else:    
    print(-1)
Buggy code:
N,M = map(int,input().split())

x = [0] * N
y = [0] * N

for i in range(M):
    s,c = map(int,input().split())
    s -= 1
    if y[s] != 0 and x[s] != c:
        ans = -1
    else:
        y[s] = 1
        x[s] = c

if y[0] == 1 and N > 1 and x[0] == 0:
    ans = -1
elif N > 1 and x[0] == 0:
    ans = 10 ** (N-1)
    for i in range(N):
        ans += x[i] * (10**(N-i-1))
else:
    ans = 0
    for i in range(N):
        ans += x[i] * (10**(N-i-1))

print(ans)
    

Fixed code:
N,M = map(int,input().split())

x = [0] * N
y = [0] * N
ans = 0

for i in range(M):
    s,c = map(int,input().split())
    s -= 1
    if y[s] != 0 and x[s] != c:
        ans = -1
    else:
        y[s] = 1
        x[s] = c

if ans == -1:
    pass
elif y[0] == 1 and N > 1 and x[0] == 0:
    ans = -1
elif N > 1 and x[0] == 0:
    ans = 10 ** (N-1)
    for i in range(N):
        ans += x[i] * (10**(N-i-1))
else:
    for i in range(N):
        ans += x[i] * (10**(N-i-1))

print(ans)
Buggy code:
import sys

n, m = map(int, input().split())
num = [-1]*n

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

num = ['0' if x == -1 else str(x) for x in num]

ans = ""
for i in num:
  ans += str(i)
ans = int(ans)

if len(''.join(num)) == n:
    print(ans)
else:
    print(-1)


Fixed code:
import sys

n, m = map(int, input().split())
num = [-1]*n

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

num = ['0' if x == -1 else str(x) for x in num]

if len(str(int(''.join(num)))) == n:
    print(''.join(num))
else:
    print(-1)
Buggy code:
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
ans = 0
exist = False
if N == 1:
  x = 0
else:
  x = 10 ** (N - 1)
for i in range(x, 1000):
  s = str(i)
  f = True
  for j in range(M):
    print(i, sc[j][0], sc[j][1], s[sc[j][0] - 1])
    if int(s[sc[j][0] - 1]) != sc[j][1]:
      f = False
      break
  if f:
    ans = i
    exist = True
    break
print(ans if exist else -1)

Fixed code:
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
ans = 0
exist = False
if N == 1:
  x = 0
else:
  x = 10 ** (N - 1)
for i in range(x, 1000):
  s = str(i)
  f = True
  for j in range(M):
    if int(s[sc[j][0] - 1]) != sc[j][1]:
      f = False
      break
  if f:
    ans = i
    exist = True
    break
print(ans if exist else -1)
Buggy code:
# coding: utf-8
# Your code here!

n,m = map(int,input().split())
a = [-1 for i in range(n)]
flag = 1
for i in range(m):
    b,c = map(int,input().split())
    b -= 1
    if a[b] != -1 and a[b] != c:
        flag = 0
        print("-1")
        break
    else:
        a[b] = c

if flag == 1:
    if a[0] == 0:
        if n == 1:
            print(0)
        else:
            print(-1)
    else:
        if a[0] == -1:
            a[0] = 1:
        ans = 0
        for i in range(n):
            if a[i] != -1:
                ans += a[i] * (10**(n-1-i))
        print(ans)

Fixed code:
# coding: utf-8
# Your code here!

n,m = map(int,input().split())
a = [-1 for i in range(n)]
flag = 1
for i in range(m):
    b,c = map(int,input().split())
    b -= 1
    if a[b] != -1 and a[b] != c:
        flag = 0
        print("-1")
        break
    else:
        a[b] = c

if flag == 1:
    if a[0] == 0:
        if n == 1:
            print(0)
        else:
            print(-1)
    else:
        if a[0] == -1:
            if n == 1:
                a[0] = 0
            else:
                a[0] = 1
        ans = 0
        for i in range(n):
            if a[i] != -1:
                ans += a[i] * (10**(n-1-i))
        print(ans)
Buggy code:
N,M = map(int, input().split())

ans  =  [-1] *  N
for i in range(M):
  s,c =  map(int, input().split())
  if ans[s-1] == -1:
    ans[s-1] = c
  elif ans[s-1] == c:
    continue
  else:
    ans = -1
    break

if ans == -1:
  print(ans)
elif ans[0] ==-1:
  print(-1)
else:
  answer = ''
  for i in range(N):
    if ans[i] ==  -1:
      ans[i]  = 1
    answer += str(ans[i])
  print(answer)

Fixed code:
N,M = map(int, input().split())

ans  =  [-1] *  N
for i in range(M):
  s,c =  map(int, input().split())
  if ans[s-1] == -1:
    ans[s-1] = c
  elif ans[s-1] == c:
    continue
  else:
    ans = -1
    break

if ans == -1:
  print(ans)
elif ans[0] == 0:
  if N == 1:
    print(0)
  else:
    print(-1)
else:
  answer = ''
  for i in range(N):
    if ans[i] ==  -1:
      if i  ==0 and N==1:
        ans[i] = 0
      elif i ==  0:
        ans[i] = 1
      else:
        ans[i]  = 0
    answer += str(ans[i])
  print(answer)
Buggy code:
n,m=map(int,input().split())
S,C=[], []
for i in range(m):
  a,b=map(int,input().split())
  S.append(a)
  C.append(b)
for j in range(10**n):
  if len(j)==n and all(str(j)[x-1]==str(y) for x,y in zip(S,C)):
    print(j)
    break;
else:
  print(-1)

Fixed code:
n,m=map(int,input().split())
S,C=[], []
for i in range(m):
  a,b=map(int,input().split())
  S.append(a)
  C.append(b)
for j in range(10**n):
  if len(str(j))==n and all(str(j)[x-1]==str(y) for x,y in zip(S,C)):
    print(j)
    break;
else:
  print(-1)
Buggy code:
N ,M = map(int,input().split())
cnt = [0]*N
C = [0]*N
C[0] = 1
for i in range(M):
    s, c = map(int,input().split())
    if cnt == 1 and C[s-1] != c:
        cnt[s-1] += 1
    elif cnt[s-1] == 1 and C[s-1] == c:
        pass
    else:
        cnt[s-1] += 1
        C[s-1] = c
if min(C) == 0 and max(C) ==0:
    print(0)
elif max(cnt)>=2 or C[0] == 0 :
    print(-1)
else:
    print("".join(map(str,C)))

Fixed code:
N ,M = map(int,input().split())
cnt = [0]*N
C = [0]*N
C[0] = 1
for i in range(M):
    s, c = map(int,input().split())
    if cnt == 1 and C[s-1] != c:
        cnt[s-1] += 1
    elif cnt[s-1] == 1 and C[s-1] == c:
        pass
    else:
        cnt[s-1] += 1
        C[s-1] = c
if N ==1 and C[0] == 0:
    print(0)
elif N ==1 and M == 0:
    print(0)
elif max(cnt)>=2 or C[0] == 0 :
    print(-1)
else:
    print("".join(map(str,C)))
Buggy code:
n, m = map(int,input().split())
a = [-1]*n
for i in range(m):
    s, c = map(int,input().split())
    if a[s-1] >= 0:
        if a[s-1] != c:
            print(-1)
            exit()
    else:
        a[s-1] = c
        print(a)

ans = ''
for t in a:
    if t:
        ans += str(t)
    else:
        ans += '0'

if n == 1 and ans[0] == '0':
    print(0)
    exit()
if ans[0] == '0':
    print(-1)
    exit()
print(ans)

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

if n == 1:
    if a[0] == -1:
        print(0)
    else:
        print(a[0])
    exit()
    
ans = ''
for i, t in enumerate(a):
    if i == 0 and t == -1:
        ans += '1'
    elif t == -1:
        ans += '0'
    else:
        ans += str(t)
print(ans)
Buggy code:
import sys
input = sys.stdin.readline
 
def main():
    N, M = map(int, input().split())
    kaburi_flag = False
    digit = [-1] * N
    for _ in range(M):
        S, C = map(int, input().split())
        if digit[S - 1] == -1:
            digit[S - 1] = C
        else:
            if not(digit[S - 1] == C):
                kaburi_flag = True
    if kaburi_flag or (digit[0] == 0 and M != 1):
        print("-1")
    else:
        if digit[0] == -1:
            digit[0] = 1
        ans = 0
        for i in range(N):
            if digit[i] == -1:
                continue
            else:
                ans += digit[i] * 10**(N - i - 1)
        print(ans)
 
if __name__ == "__main__":
    main()

Fixed code:
import sys
input = sys.stdin.readline
 
def main():
    N, M = map(int, input().split())
    kaburi_flag = False
    digit = [-1] * N
    for _ in range(M):
        S, C = map(int, input().split())
        if digit[S - 1] == -1:
            digit[S - 1] = C
        else:
            if not(digit[S - 1] == C):
                kaburi_flag = True
    if not(kaburi_flag) and (N == 1):
        if digit[0] == -1:
            print("0")
        else:
            print(digit[0])
    elif kaburi_flag or digit[0] == 0:
        print("-1")
    else:
        if digit[0] == -1:
            digit[0] = 1
        ans = 0
        for i in range(N):
            if digit[i] == -1:
                continue
            else:
                ans += digit[i] * 10**(N - i - 1)
        print(ans)
 
if __name__ == "__main__":
    main()
Buggy code:
import sys

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

ans = []
for _ in range(n):
    ans.append('a')

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

ans = ''.join(ans).replace('a', '0')

if ans[0] == '0':
    ans.replace('0', '1', 1)

print(int(ans))


Fixed code:
import sys

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

ans = []
for _ in range(n):
    ans.append('a')

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

if ans[0] == '0' and len(ans) != 1:
    print(-1)
    sys.exit()
elif len(ans) == 1:
    if ans[0] == 'a':
        print(0)
        sys.exit()
    else:
        print(int(ans[0]))
        sys.exit()

ans = ''.join(ans).replace('a', '0')

if ans[0] == '0':
    ans = ans.replace('0', '1', 1)

print(int(ans))
Buggy code:
n,m = map(int,input().split())
ketasuu,content = [],[]
for _ in range(m):
    s,c = map(int,input().split())
    ketasuu.append(s-1)
    content.append(c)
ans = 10000-1
for i in range(0,10000):
    tmp =list(str(i)) 
    flag = []
    for j in range(m):
        try:
            if tmp[ketasuu[j]] == str(content[j]):
                flag.append(True)
            else:
                flag.append(False)
        except:
            pass
    if all(flag) and len(tmp)==n:
        ans = min(i,ans)
if ans == 10000:
    print(-1)
else:
    print(ans)

Fixed code:
n,m = map(int,input().split())
ketasuu,content = [],[]
for _ in range(m):
    s,c = map(int,input().split())
    ketasuu.append(s-1)
    content.append(c)
ans = 10000-1
for i in range(0,10000):
    tmp =list(str(i)) 
    flag = []
    for j in range(m):
        try:
            if tmp[ketasuu[j]] == str(content[j]):
                flag.append(True)
            else:
                flag.append(False)
        except:
            pass
    if all(flag) and len(tmp)==n:
        ans = min(i,ans)
if ans == 10000-1:
    print(-1)
else:
    print(ans)