qyliang/CodeNanoFix huggingface dataset:
Buggy code:
def main():
    n, m = map(int, input().split())
    ans = [0] * n
    count = [0] * n
    for i in range(m):
        s, c = map(int, input().split())
        if s == 1 and c == 0:
            print(-1)
            exit()
        if count[s - 1] == 0:
            ans[s - 1] = c
            count[s - 1] += 1
        else:
            print(-1)
            exit()
    if ans[0] == 0:
        ans[0] = 1
    print(''.join(map(str, ans)))


if __name__ == '__main__':
    main()


Fixed code:
def main():
    n, m = map(int, input().split())
    ans = [0] * n
    count = [0] * 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 count[s - 1] == 0 or ans[s - 1] == c:
            ans[s - 1] = c
            count[s - 1] += 1
        else:
            print(-1)
            exit()
    if ans[0] == 0 and n != 1:
        ans[0] = 1
    print(''.join(map(str, ans)))


if __name__ == '__main__':
    main()
Buggy code:
n,m=map(int,input().split())
SC=[list(map(int,input().split())) for _ in range(m)]

for i in range(10*n):
    num=str(i)
    if len(num)==n and all(num[s-1]==str(c) for s,c in SC):
        print(i)
        break
else:
    print(-1)


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

for i in range(10**n):
    if len(str(i))==n and all(str(i)[s-1]==str(c) for s,c in SC):
        print(i)
        break
else:
    print(-1)
Buggy code:
N, M = map(int, input().split())
S = []
C = []
for i in range(M):
    s, c = input().split()
    S.append(int(s))
    C.append(int(c))

A = [0]*N
for a, b in zip(S, C):
    if a == 1 and b == 0:
        if N != 1:
            print(-1)
            exit()
    if a == 2 and b == 0:
        if N != 3:
            print(-1)
            exit()
    A[a-1] = b

if N == 3 and A[0] == 0:
    A[0] = 1

if N == 2 and A[0] == 0:
    A[0] = 1
for a in A:
    print(a, end="")


Fixed code:
N, M = map(int, input().split())
S = []
C = []
for i in range(M):
    s, c = input().split()
    S.append(int(s))
    C.append(int(c))


A = ["x"]*N
for a, b in zip(S, C):
    if A[a-1] == "x":
        A[a-1] = b
    else:
        if b == A[a-1]:
            A[a-1] = b
        else:
            print(-1)
            exit()

if N != 1 and A[0] == "x":
    A[0] = 1

if A[0] == "x":
    if N != 1:
        print(-1)
        exit()
if A[0] == 0 and N != 1:
    print(-1)
    exit()

for a in range(N):
    if A[a-1] == "x":
        A[a-1] = 0
for a in A:
    print(a, end="")
Buggy code:
N, M = list(map(int, input().split()))
SC = [list(map(int, input().split())) for _ in range(M)]

for i in range(1000):
    t = str(i)
    if all((len(t) > s-1) and int(t[s-1]) == (c)  for s, c in SC):
        print(i)
        exit()
print(-1)


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

for i in range(1000):
    t = str(i)
    if len(t) == N and all([(len(t) > s-1) and (int(t[s-1]) == c) for s, c in SC]):
        print(i)
        exit()
print(-1)
Buggy code:
# import math
# import bisect
# import heapq
# from collections import deque
import numpy as np

n,m = map(int,input().split())
s,c = [0] * m, [0] * m
for i in range(m):
    s[i],c[i] = map(int,input().split())

# replace = [False] * n
ans = list('a'* n)

for i in range(m):

    if len(ans) != 1 and s[i] == 1 and c[i] == 0:
        ans = -1
        break
    elif ans[s[i]-1] != 'a' and str(c[i]) != ans[s[i]-1]:
        ans = -1
        break

    ans[s[i]-1] = str(c[i])
if n == 1 and ans[0] == 0: print(0)

elif not ans == -1:

    for i in range(n):
        if i == 0 and ans[i] == 'a': ans[0] = '1'
        elif ans[i] == 'a': ans[i] = '0'

    print(''.join(ans))

elif : print(-1)


Fixed code:
# import math
# import bisect
# import heapq
# from collections import deque
import numpy as np

n, m = map(int, input().split())
s, c = [0] * m, [0] * m
for i in range(m):
    s[i], c[i] = map(int, input().split())

# replace = [False] * n
number = ['a'] * n
ans = 0
for i in range(m):

    if number[s[i]-1] != 'a' and str(c[i]) != number[s[i]-1]:
        ans = -1
        break

    number[s[i]-1] = str(c[i])

if not ans == -1:
    for i in range(n):
        if i == 0 and number[i] == 'a' and len(number) != 1:
            number[0] = '1'
        elif number[i] == 'a':
            number[i] = '0'
    ans = ''.join(number)

    if n != 1 and number[0] == '0':
        ans = -1
print(ans)
Buggy code:
N,M = map(int,input().split())
array = [0]*N
T_F = True

for i in range(M):
  s,c = map(int,input().split())
  if s>N or (array[s-1] != 0 and array[s-1] !=c):
    T_F = False
    break
  else:
    array[s-1] = c
ans = 0
for i in range(N):
  ans += array[i]*(10**(N-i-1))
if T_F:
  if array[0]:
    print(ans)
  else:
    print(ans+10**(N-1))
else:
  print(-1)
  
  

Fixed code:
N,M = map(int,input().split())
array = [10]*N
T_F = True

for i in range(M):
  s,c = map(int,input().split())
  if s>N or (array[s-1] != 10 and array[s-1] !=c) or (s == 1 and c == 0 and N != 1):
    T_F = False
    break
  else:
    array[s-1] = c

ans = 0
if T_F:
  for i in range(N):
    if array[i] == 10:
        array[i] = 0
    ans += array[i]*(10**(N-i-1))
  if array[0] or N == 1:
    print(ans)
  else:
    print(ans+10**(N-1))
else:
  print(-1)
Buggy code:
n, m = map(int, input().split())

dic = [set() for _ in range(n)]

#print(dic)

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

ans = 0
mul = 10 ** (n-1)

for i in range(len(dic)) :
    ans += (list(dic[i])[0] * mul)
    mul /= 10

print(int(ans))


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

dic = [set() for _ in range(n)]

#print(dic)

for i in range(m) :
    s, c = map(int, input().split())
    dic[s-1].add(c)
#print(dic, list(dic[0])[0])
#print(dic)
for i in range(len(dic)) :
    if len(dic[i]) > 1 :
        print(-1)
        exit()
    if n != 1 and len(dic[i]) == 1 and i == 0:
        if list(dic[i])[0] == 0 :
            print(-1)
            exit()
    if len(dic[i]) == 0 :
        if i == 0 and m != 0:
            dic[i].add(1)
        elif m == 0 and n > 1 and i == 0:
            dic[i].add(1)
        else :
            dic[i].add(0)

ans = 0
mul = 10 ** (n-1)

for i in range(n) :
    ans += (list(dic[i])[0] * mul)
    mul /= 10

print(int(ans))
Buggy code:
N, M = map(int, input().split())
num = [x for x in str(10**(N - 1))]
confirmed_or_not = [False] * N

for _ in range(M):
    s, c = map(int, input().split())
    if s > N:
        num = ['-1']
        break
    
    if s == 1 and c == 0:
        if N > 1:
            num = ['-1']
            break
        
    if confirmed_or_not[s-1] and num[s-1] != str(c):
        num = ['-1']
        break
        
    num[s - 1] = str(c)
    confirmed_or_not[s-1] = True


if N == 1 and not confirmed_or_not[0]:
    num = ['0']

print(*num)

Fixed code:
N, M = map(int, input().split())
num = [x for x in str(10**(N - 1))]
confirmed_or_not = [False] * N

for _ in range(M):
    s, c = map(int, input().split())
    
    if s == 1 and c == 0:
        if N > 1:
            num = ['-1']
            break
        
    if confirmed_or_not[s-1] and num[s-1] != str(c):
        num = ['-1']
        break
        
    num[s - 1] = str(c)
    confirmed_or_not[s - 1] = True


if N == 1 and not confirmed_or_not[0]:
    num = ['0']

print(*num, sep='')
Buggy code:
n, m = (int(i) for i in input().split());

num = [-1 for i in range(n)];

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

for i in range(n):
    print(max(num[i], int(i == 0)), end="");


Fixed code:
n, m = (int(i) for i in input().split());

num = [-1 for i in range(n)];

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

if n == 1 and num[0] <= 0:
    print(max(num[0], 0));
    exit(0);

if num[0] == 0:
    print('-1');
    exit(0);

for i in range(n):
    print(max(num[i], int(i == 0)), end="");
Buggy code:
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 

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

Fixed code:
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 

n,m=map(int,input().split())
a=[]
for i in range(n):
  a.append(0)
b=[]
if n==1:
  b.append(0)
else:
  b.append(1)
  for i in range(n-1):
    b.append(0)
fail=0
for i in range(m):
  s,c=map(int,input().split())
  if c!= b[s-1] and a[s-1]==1:
    fail=1
    break
  b[s-1]=c
  a[s-1]=1
if n>1 and b[0]==0:
  fail=1
for i in range(n):
  b[i]=str(b[i])

if fail==1:
  print(-1)
else:
  print(convert(b))
Buggy code:
N,M = list(map(int,input().split()))
A = ['0']*N
for i in range(M):
  s,c = list(map(int,input().split()))
  if A[s-1] != '0' and A[s-1] != str(c):
    print('-1')
    exit()
  else:
    A[s-1] = str(c)
print(''.join(A))

Fixed code:
N,M = list(map(int,input().split()))
A = ['a']*N
for i in range(M):
  s,c = list(map(int,input().split()))
  if A[s-1] != 'a' and A[s-1] != str(c):
    print('-1')
    exit()
  else:
    A[s-1] = str(c)
if A[0] == '0' and len(A) != 1:
  print('-1')
  exit()
elif A[0] == 'a' and len(A) != 1:
  A[0] = '1'
for i in range(N):
      if A[i] == 'a':
        A[i] = '0'
print(''.join(A))
Buggy code:
import sys
n,m=map(int,input().split())
s=[]
c=[]
for i in range(m):
    st,ct=map(int,input().split())
    s.append(st)
    c.append(ct)
ans=[[0,0] for i in range(n)]
for i in range(m):
    if s[i]==1 and c[i]==0 and n>=2:
        print(-1)
        sys.exit()
    if ans[s[i]-1][1]==0:
        ans[s[i]-1][0]=c[i]
        ans[s[i]-1][1]=1
    else:
        if ans[s[i]-1][0] != c[i]:
            print(-1)
            sys.exit()
if ans[0][0]==0 and n>=2:
    ans[0][0]=1
ansn=0
for i in range(n):
    ansn+=ansn[i][0]*10**(n-i-1)
print(ansn)
        
        

Fixed code:
n,m=map(int,input().split())
s=[]
c=[]
for i in range(m):
    st,ct=map(int,input().split())
    s.append(st)
    c.append(ct)
ans=[[0,0] for i in range(n)]
for i in range(m):
    if s[i]==1 and c[i]==0 and n>=2:
        print(-1)
        exit()
    if ans[s[i]-1][1]==0:
        ans[s[i]-1][0]=c[i]
        ans[s[i]-1][1]=1
    else:
        if ans[s[i]-1][0] != c[i]:
            print(-1)
            exit()
if ans[0][0]==0 and n>=2:
    ans[0][0]=1
ansn=0
for i in range(n):
    ansn+=ans[i][0]*10**(n-i-1)
print(ansn)
Buggy code:
# -*- coding: utf-8 -*-
import sys

[N, M] = [int(i) for i in input().split()]

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

ans_str = ['0'] * N

print(ans_str)

for (s, c) in SC:
    if ans_str[s - 1] != '0' and ans_str[s - 1] != str(c):
        print(-1)
        sys.exit()
        
    ans_str[s - 1] = str(c)

print(ans_str)

for s in ans_str:
    if s != '0':
        break
else:
    print(-1)
    sys.exit()

for i in range(len(ans_str)):
    if ans_str[i] == '0':
        ans_str[i] = '1'
    else:
        break

ans = ''.join(ans_str)
print(int(ans))

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

[N, M] = [int(i) for i in input().split()]

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

ans_str = ['-1'] * N

for (s, c) in SC:
    if ans_str[s - 1] != '-1' and ans_str[s - 1] != str(c):
        print(-1)
        sys.exit()
    if s == 1 and c == 0 and N != 1:
        print(-1)
        sys.exit()
        
    ans_str[s - 1] = str(c)

if N == 1:
    if ans_str[0] == '-1':
        ans_str[0] = '0'
else:
    for i in range(len(ans_str)):
        if ans_str[i] == '-1':
            if i == 0:
                ans_str[i] = '1'
            else:
                ans_str[i] = '0'

ans = ''.join(ans_str)
print(int(ans))
Buggy code:
n, m = map(int, input().split())

ans = ["-" for _ in range(n)]

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

for a in ans:
    if a == "-":
        print(1, end="")
    else:
        print(a, end="")



Fixed code:
n, m = map(int, input().split())
if n == 1 and m == 0:
    print(0)
    exit()
ans = ["-" for _ in range(n)]

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

for i, a in enumerate(ans):
    if i == 0:
        if a == "-":
            print(1, end="")
        else:
            print(a, end="")
    else:
        if a == "-":
            print(0, end="")
        else:
            print(a, end="")
Buggy code:
def lstToInt(l,x=0):
  if len(l) == 0:
    return x
  else:
    return lstToInt(l[1:], x*10 + l[0])

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

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

Fixed code:
def lstToInt(l,x=0):
  if len(l) == 0:
    return x
  else:
    return lstToInt(l[1:], x*10 + l[0])

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

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

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

ans = lstToInt(list(0 if c[i] == -1 else c[i] for i in range(n)))
print(ans)
Buggy code:
N, M = map(int, input().split())
ans = [-1] * N
for _ in range(M):
    i, n = map(int, input().split())
    if ans[i-1] == -1 or ans[i-1] == n:
        ans[i-1] = n
    else:
        print(-1)
        exit()
ans = [n if n != -1 else 0 for n in ans]
if ans[0] == 0 and len(ans > 1):
    ans[0] = 1
print(*ans, sep='')

Fixed code:
N, M = map(int, input().split())
ans = [-1] * N
for _ in range(M):
    i, n = map(int, input().split())
    if (ans[i-1] == -1 or ans[i-1] == n) and not(N > 1 and i == 1 and n == 0):
        ans[i-1] = n
    else:
        print(-1)
        exit()
ans = [n if n != -1 else 0 for n in ans]
if ans[0] == 0 and N > 1:
    ans[0] = 1

print(*ans, sep='')
Buggy code:
import sys
N,M = map(int, input(). split())
s = [0,]*M
c = [0,]*M
ans =[10,]*N
for i in range(M):
    s[i], c[i] = map(int, input(). split())
    if ans[s[i]-1] != 10 and ans[s[i]-1] != c[i]:
        print(-1)
        sys.exit()
    else:
        ans[s[i]-1] = c[i]
if ans[0] == 0:
    print(-1)
    sys.exit()
elif ans[0] == 10:
    ans[0] = 1
    A = 0
    for j in range(N):
        if ans[j] == 10:
            ans[j] = 0
    for k in range(N):
        A += 10**(M-k)*ans[k] 
    print(A)
        
else:
    A = 0
    for j in range(N):
        if ans[j] == 10:
            ans[j] = 0
    for k in range(N):
        A += 10**(M-k)*ans[k] 
    print(A)
    
    


    

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

s = [0,]*M
c = [0,]*M
ans =[10,]*N



for i in range(M):
    s[i], c[i] = map(int, input(). split())
    if ans[s[i]-1] != 10 and ans[s[i]-1] != c[i]:
        print(-1)
        sys.exit()
    else:
        ans[s[i]-1] = c[i]       
if N >= 2:
        
    A = 0        
    if ans[0] == 0:
        print(-1)
        sys.exit()
    elif ans[0] == 10:
        ans[0] = 1
        for j in range(N):
            if ans[j] == 10:
                ans[j] = 0
        for k in range(N):
            A += 10**(N-k-1)*ans[k] 
    
        print(A)
        
    else:
        for j in range(N):
            if ans[j] == 10:
                ans[j] = 0
        for k in range(N):
            A += 10**(N-k-1)*ans[k] 
        print(A)
else:
    A = 0
    if ans[0] == 0 or ans[0] == 10:
        print(0)
    else:
        print(ans[0])
Buggy code:
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N, M = inpl()
dp = [-1] * N
for _ in range(M):
    s, c = inpl()
    s -= 1
    if dp[s] not in [-1, c]:
        print(-1)
        sys.exit()
    dp[s] = c
for i in range(N):
    if N == 1:
        if dp[i] == -1:
            print(0, end='')
        else:
            print(dp[i], end='')
    else:
        if i == 0:
            if dp[i] == -1:
                print(1, end='')
            else:
                print(dp[i], end='')
        else:
            if dp[i] == -1:
                print(0, end='')
            else:
                print(dp[i], end='')
                
print()
# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Fixed code:
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N, M = inpl()
dp = [-1] * N
for _ in range(M):
    s, c = inpl()
    s -= 1
    if dp[s] not in [-1, c]:
        print(-1)
        sys.exit()
    dp[s] = c
for i in range(N):
    if N == 1:
        if dp[i] == -1:
            print(0, end='')
        else:
            print(dp[i], end='')
    else:
        if i == 0:
            if dp[i] == -1:
                print(1, end='')
            elif dp[i] == 0:
                print(-1)
                sys.exit()
            else:
                print(dp[i], end='')
        else:
            if dp[i] == -1:
                print(0, end='')
            else:
                print(dp[i], end='')
                
print()
# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)
Buggy code:
n, m = map(int, input().split())
rules = []

for x in range(m):
  rules.append(list(map(int, input().split())

def get_ans():
  if m == 0:
      return(10**(n-1)*int(bool(1<n)))

  for i in range(10**(n-1)*int(bool(1<n)), 10**n):
      for j, rule in enumerate(rules):

          if int(str(i)[rule[0]-1]) == rule[1]:
              if j == len(rules)-1:
                  return(i)
              else:
                  continue
          else:
              break
      return(-1)


print(get_ans())                    


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

def get_ans():
    if m == 0:
        return(10**(n-1)*int(bool(1<n)))
        
    for i in range(10**(n-1)*int(bool(1<n)), 10**n):
        for j, rule in enumerate(rules):
            
            if int(str(i)[rule[0]-1]) == rule[1]:
                if j == len(rules)-1:
                    return(i)
                else:
                    continue
            else:
                break
                
    return(-1)


print(get_ans())
Buggy code:
N, M = map(int, input().split())
N_list = [0] * N
N_set_list = [False] * N

for i in range(M):
  s, c = map(int, input().split())
  s -= 1
  
  if s > N -1 or (s == 0 and c == 0):
    print(-1)
    exit()

  elif N_set_list[s] and (N_list[s] != c):
    print(-1)
    exit()

  else:
    N_list[s] = c
    N_set_list[s] = True

if N_list[0] == 0 and len(N_list) != 1
  N_list[0] = 1

print(''.join(map(str, N_list)))


Fixed code:
N, M = map(int, input().split())
N_list = [0] * N
N_set_list = [False] * N

for i in range(M):
  s, c = map(int, input().split())
  s -= 1
  
  if s > N -1 or (s == 0 and c == 0 and N != 1):
    print(-1)
    exit()

  elif N_set_list[s] and (N_list[s] != c):
    print(-1)
    exit()

  else:
    N_list[s] = c
    N_set_list[s] = True

if N_list[0] == 0 and N != 1:
  N_list[0] = 1

print(''.join(map(str, N_list)))
Buggy code:
N, M = list(map(int, input().split()))
sc = [list(map(int, input().split())) for i in range(M)]

answer = [None] * N
for si, ci in sc:
    digit = si - 1
    if answer[digit] is not None and answer[digit] != ci:
        print(-1)
        exit()
    
    answer[digit] = ci

for i, value in enumerate(answer):
    print(i)
    if answer[i] is None:
        answer[i] = 0

if answer[0] == 0:
    print(-1)
    exit()

answer = ''.join(map(str, answer))
print(answer)


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

answer = [None] * N
for si, ci in sc:
    digit = si - 1
    if answer[digit] is not None and answer[digit] != ci:
    # if answer[digit] != ci:
        print('-1')
        exit()
    
    answer[digit] = ci

if answer[0] == 0 and N != 1:
    print('-1')
    exit()

if answer[0] is None and N == 1:
    answer[0] = 0
elif answer[0] is None:
    answer[0] = 1

for i, value in enumerate(answer):
    if answer[i] is None:
        answer[i] = 0

answer = int(''.join(map(str, answer)))
print(answer)
Buggy code:
n,m = map(int,input().split())
ans = []
for i in range(n):
    ans.append(0)
for k in range(m):
    s,c = map(int,input().split())
    if c == 0:
        c = 10    
    if ans[s-1] == 0 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print('-1')
        exit()
if ans[0] == 10:
    print('-1')
    exit()
ans = [str(s) for s in ans]
print(ans)
if ans[0] == "0":
    ans[0] = "1"
ans = [s.replace("10","0") for s in ans]
print("".join(ans))

Fixed code:
n,m = map(int,input().split())
ans = []
for i in range(n):
    ans.append(0)
for k in range(m):
    s,c = map(int,input().split())
    if c == 0:
        c = 10    
    if ans[s-1] == 0 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print('-1')
        exit()
if n != 1:
    if ans[0] == 10:
        print('-1')
        exit()
ans = [str(s) for s in ans]
if n != 1:
    if ans[0] == "0":
       ans[0] = "1"
ans = [s.replace("10","0") for s in ans]
print("".join(ans))
Buggy code:
n = []

N, M = list(map(int, input().split()))
for i in range(N):
    n.append('W')

for i in range(M):
    s, c = list(map(int, input().split()))
    s -= 1
    if n[s] == "W":
        n[s] = c
    elif n[s] == c:
        pass
    else:
        print(-1)
        exit()
        
if N != 0:
    if n[0] == 0:
        print(-1)
    
    if n[0] == "W":
        n[0] == 1
        
    for i in range(N):
        if n[i] =="W":
            n[i] = 0

else:
    if n[0] == -1:
        n[0] = 0
        
print(''.join(map(str,n)))

Fixed code:
n = []

N, M = list(map(int, input().split()))
for i in range(N):
    n.append('W')

for i in range(M):
    s, c = list(map(int, input().split()))
    s -= 1
    if n[s] == "W":
        n[s] = c
    elif n[s] == c:
        pass
    else:
        print(-1)
        exit()
        
if N != 1:
    if n[0] == 0:
        print(-1)
        exit()
    
    if n[0] == "W":
        n[0] = 1
        
    for i in range(N):
        if n[i] =="W":
            n[i] = 0

else:
    if n[0] == "W":
        n[0] = 0
        
print(''.join(map(str,n)))