qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N,M=map(int,input().split())
p=True
l=[-1 for _ in range(N)]
for i in range(M):
  s,c=map(int,input().split())
  if l[s-1] == -1:
    l[s-1] = c
  elif not l[s-1]==c:
    p=False
if p:
  ans=""
  if l[0]==0:
    p=False
  elif l[0]==-1:
    if len(l)==1:
      ans="0"
    else:
      ans="1"
  else:
    ans=str(l[0])
  for i in l[1:]:
    if i == -1:
      ans+="0"
    else:
      ans+=str(i)
print(int(ans) if p else -1)
print(l)

Fixed code:
N,M=map(int,input().split())
p=True
l=[-1 for _ in range(N)]
for i in range(M):
  s,c=map(int,input().split())
  if l[s-1] == -1:
    l[s-1] = c
  elif not l[s-1]==c:
    p=False
if p:
  ans=""
  if len(l) == 1:
    if l[0] == -1:
      ans = "0"
    else:
      ans = str(l[0])
  elif l[0]==0:
    p=False
  elif l[0]==-1:
    ans="1"
  else:
    ans=str(l[0])
  for i in l[1:]:
    if i == -1:
      ans+="0"
    else:
      ans+=str(i)
print(int(ans) if p else -1)
Buggy code:
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
print(sc)
for i in range(10**n):
  i2=str(i)
  print(i2)
  if len(i2)==n and all([i2[s-1]==str(c) for s,c in sc]):
      print(i2)
      exit()
print(-1)

Fixed code:
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
# print(sc)
for i in range(10**n):
  i2=str(i)
#   print(i2)
  if len(i2)==n and all([i2[s-1]==str(c) for s,c in sc]):
      print(i2)
      exit()
print(-1)
Buggy code:
n,m=map(int,input().split())
a=[-1]*n
v=[0]*n
f=0
for _ in range(m):
	s,c=map(int,input().split())
	if(v[s-1]==0 or a[s-1]==c):
		v[s-1]=1
		a[s-1]=c
	else:
		f=1
s1='a'
if n!=1 and a[0]==-1:
	a[0]=1
for x in a:
	s1+=str(x)
if f==1 or (n!=1 and s1[1]=='0'):
	print(-1)
else:
	print(s1[1:])


Fixed code:
n,m=map(int,input().split())
a=[-1]*n
v=[0]*n
f=0
for _ in range(m):
	s,c=map(int,input().split())
	if(v[s-1]==0 or a[s-1]==c):
		v[s-1]=1
		a[s-1]=c
	else:
		f=1
s1='a'
if n!=1 and a[0]==-1:
	a[0]=1
for x in a:
	if x==-1:
		x=0
	s1+=str(x)
if f==1 or (n!=1 and s1[1]=='0'):
	print(-1)
else:
	print(s1[1:])
Buggy code:
n, m = map(int, input().split())

cond = []
for _ in range(m):
    s, c = map(int, input().split())
    cond.append((s, c))
inf = float('infinity')
ans = inf
for i in range(1, 10 ** n):
    string = str(i)
    if len(string) != n:
        continue
    print(i)
    for s, c in cond:
        if len(string) < s:
            break
        if string[s - 1] == str(c):
            continue
        else:
            break
    else:
        ans = min(ans, i)
if ans == inf:
    print(-1)
else:
    print(ans)

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

cond = []
for _ in range(m):
    s, c = map(int, input().split())
    cond.append((s, c))
inf = float('infinity')
ans = inf
for i in range(10 ** n):
    string = str(i)
    if len(string) != n:
        continue
    for s, c in cond:
        if len(string) < s:
            break
        if string[s - 1] == str(c):
            continue
        else:
            break
    else:
        ans = min(ans, i)
if ans == inf:
    print(-1)
else:
    print(ans)
Buggy code:
N,M = list(map(int,input().split()))
S = list("*"*N)
for i in range(M):
    s,c = list(map(int,input().split()))
    if S[s-1] == '*':
        S[s-1]=str(c)
        if S[0]==0:
            print(-1)
            exit()
    
    elif S[s-1]!=str(c):
        print(-1)
        exit()
if S[0]=='*':
    S[0]='1'
for i in range(N):
    if S[i] == '*':
        S[i] = '0'
print("".join(S))
    


Fixed code:
N,M = list(map(int,input().split()))
S = list("*"*N)
for i in range(M):
    s,c = list(map(int,input().split()))
    if S[s-1] == '*':
        S[s-1]=str(c)
        if S[0]=='0' and N != 1:
            print(-1)
            exit()
    
    elif S[s-1]!=str(c):
        print(-1)
        exit()
if S[0]=='*' and N>1:
    S[0]='1'
elif S[0] == '*' and N == 1:
    S[0] = '0'

for i in range(N):
    if S[i] == '*':
        S[i] = '0'
print("".join(S))
Buggy code:
n,m = map(int, input().split())
s=[]
for i in range(m):
  s.append(list(map(int, input().split())))

for i in range(1000):
  for si in s:
    if len(str(i)) < si[0]:
      break
    if str(i)[si[0]-1] != str(si[1]):
      break
  else:
    print(i)
    break
else:
  print(-1)


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

for i in range(1000):
  if len(str(i)) != n:
    continue
  for si in s:
    if len(str(i)) < si[0]:
      break
    if str(i)[si[0]-1] != str(si[1]):
      break
  else:
    print(i)
    break
else:
  print(-1)
Buggy code:
n, m = map(int,input().split())

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

pf = True
for i in range(m):
    s,c = map(int,input().split())
    if (not ans[s-1] == -1) and (not ans[s-1] == c):
        print(-1)
        pf = False
        break
    else:
        ans[s-1] = c

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


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


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

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

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

if pf and n == 1:
    if ans[0] == -1:
        print(0)
    else:
        print(ans[0])
elif pf:
    if ans[0] == -1:
        ans[0] = 1
    for i in range(n):
        if ans[i] == -1:
            ans[i] = 0
    print(''.join(map(str,ans)))
Buggy code:
 coding: utf-8

N, M = list(map(int, input().split()))
begin = 0 if N == 1 else 10**(N-1)

sc = [[i for i in map(int, input().split())] for j in range(M)]

for i in range(begin, 10**N):
    flag = True
    for j in range(M):
        if str(i)[sc[j][0]-1] != str(sc[j][1]):
            flag = False
            break

    if flag == True:
        print(i)
        break

if flag == False: print(-1)

Fixed code:
# coding: utf-8

N, M = list(map(int, input().split()))
begin = 0 if N == 1 else 10**(N-1)

sc = [[i for i in map(int, input().split())] for j in range(M)]

for i in range(begin, 10**N):
    flag = True
    for j in range(M):
        if str(i)[sc[j][0]-1] != str(sc[j][1]):
            flag = False
            break

    if flag == True:
        print(i)
        break

if flag == False: print(-1)
Buggy code:
n,m=map(int,input().split())
l=[-1]*n
check=False
for i in range(m):
    s,c=map(int,input().split())
    if s==1 and c==0:
        break
    if l[s-1]==-1 or l[s-1]==c:
        l[s-1]=c
    else:
        break
    if i==m-1:
        check=True
if n!=1 and l[1]==-1:
    l[1]=1
if check:
    for num in l:
        if num==-1:
            print(0,end='')
        else:
            print(num,end='')
    print()
else:
    print(-1)


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

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

if m!=0 and check:
    for num in l:
        if num==-1:
            print(0,end='')
        else:
            print(num,end='')
    print()
elif n==1 and m==0:
    print(0)
elif m==0:
    print(10**(n-1))
else:
    print(-1)
Buggy code:
def main():
    n, m = map(int, input().split())
    s, c = []*m, []*m
    for i in range(m):
        a, b = map(int, input())
        s.append(a), c.append(b)
    for i in range(0, 10 ** n):
        loop = True
        string = str(i)
        if len(string) != n:
            continue
        for j in range(m):
            if string[s[j] - 1] != str(c[j]):
                loop = False
        if loop:
            print(string)
            quit()
    print(-1)
if __name__ == "__main__":
    main()

Fixed code:
def main():
    n, m = map(int, input().split())
    s, c = []*m, []*m
    for i in range(m):
        a, b = map(int, input().split())
        s.append(a), c.append(b)
    for i in range(0, 10 ** n):
        loop = True
        string = str(i)
        if len(string) != n:
            continue
        for j in range(m):
            if string[s[j] - 1] != str(c[j]):
                loop = False
        if loop:
            print(string)
            quit()
    print(-1)
if __name__ == "__main__":
    main()
Buggy code:
n,m=map(int,input().split())
ans=["a"]*n
for i in range(0,m):
  s,c=map(int,input().split())
  if ans[s-1]=="a" or ans[s-1]==c:
    ans[s-1]=c
  else:
    print(-1)
    break
else:
  for i in range(0,n):
    if ans[i]=="a":
      ans[i]=0
  if n==3:
    ans=int(ans[0])*100+int(ans[1])*10+int(ans[2])
  elif n==2:
    ans=int(ans[0])*10+int(ans[1])
  else:
    ans=int(ans[0])
  print(ans)

Fixed code:
n,m=map(int,input().split())
ans=["a"]*n
for i in range(0,m):
  s,c=map(int,input().split())
  if ans[s-1]=="a" or ans[s-1]==c:
    ans[s-1]=c
  else:
    print(-1)
    break
else:
  if n==1 and ans[0]=="a":
    ans[0]=0
  elif ans[0]=="a":
    ans[0]=1
  for i in range(0,n):
    if ans[i]=="a":
      ans[i]=0
  if i>=2 and ans[0]==0:
    print(-1)
  else:
    if n==3:
      ans=int(ans[0])*100+int(ans[1])*10+int(ans[2])
    elif n==2:
      ans=int(ans[0])*10+int(ans[1])
    else:
      ans=int(ans[0])
    print(ans)
Buggy code:
N,M = map(int,input().split())
 
m = []
for i in range(M):
    m.append(list(map(int,input().split())))
for i in range(10**N):
    a = str(i)
    
    if i >= 10**(N-1):
            
        for j in range(M):
            try:
                
                if a[m[j][0]-1] == str(m[j][1]):
                    True
                
                else:
                    break
            except:
                break
                
            if j == M-1:
                print(i)
                exit()   
if M==0:
    if N == 1:
        print(0)
    else:
        print(10**(N-1))
        
if M==1:
    if N == 1:
        if m[0][1]==0:
            print(0)
else :
    print(-1)

Fixed code:
N,M = map(int,input().split())
 
m = []
for i in range(M):
    m.append(list(map(int,input().split())))
for i in range(10**N):
    a = str(i)
    
    if i >= 10**(N-1):
            
        for j in range(M):
            try:
                
                if a[m[j][0]-1] == str(m[j][1]):
                    True
                
                else:
                    break
            except:
                break
                
            if j == M-1:
                print(i)
                exit()
                
if M==0:
    if N == 1:
        print(0)
        
    else:
        print(10**(N-1))
        
    exit()

elif M==1:
    if N == 1:
        m == [[1,0]]
        print(0)
        exit()


print(-1)
Buggy code:
N,M = [int(i) for i in input().rstrip().split()]
n = 1 if N > 1 else 0
C = [list(range(n,10))] + [list(range(10)) for i in range(N-1)]

for m in range(M):
    s,c = [int(i) for i in input().rstrip().split()]
    s -= 1
    if c in C[s]:
        C[s] = [c]
    else:
        print(-1)
        exit()
    print(C)
C = [str(min(c)) for c in C]
print("".join(C))


Fixed code:
N,M = [int(i) for i in input().rstrip().split()]
n = 1 if N > 1 else 0
C = [list(range(n,10))] + [list(range(10)) for i in range(N-1)]

for m in range(M):
    s,c = [int(i) for i in input().rstrip().split()]
    s -= 1
    if c in C[s]:
        C[s] = [c]
    else:
        print(-1)
        exit()
    #print(C)
C = [str(min(c)) for c in C]
print("".join(C))
Buggy code:
N,M = map(int,input().rstrip().split(" "))
ans = 0
n = [-1 for i in range(N)]
for i in range(M):
  s,c = map(int,input().rstrip().split(" "))
  s -= 1
  if n[s] == -1 or n[s] == c:
    n[s] = c
  else:
    ans = -1
if N != 1 and n[0] == 0:
  ans = -1

if ans == -1:
  print(-1)
if N == 0 and M == 0:
  print(0)
else:
  for i in range(N):
    if n[i] == -1:
      if i == 0:
        ans = ans + 10 ** (N -1)
    else:
      ans += 10 ** (N - i -1) * n[i]
  print(ans)

Fixed code:
N,M = map(int,input().rstrip().split(" "))
ans = 0
n = [-1 for i in range(N)]
for i in range(M):
  s,c = map(int,input().rstrip().split(" "))
  s -= 1
  if n[s] == -1 or n[s] == c:
    n[s] = c
  else:
    ans = -1
if N != 1 and n[0] == 0:
  ans = -1

if ans == -1:
  print(-1)
elif N == 1 and M == 0:
  print(0)
else:
  for i in range(N):
    if n[i] == -1:
      if i == 0:
        ans += 10 ** (N -1)
    else:
      ans += 10 ** (N - i -1) * n[i]
  print(ans)
Buggy code:
    import sys
     
    def get_minimun_val(n, rule_dict):
      max_val = 10**n
      min_val = 10**(n-1)
      for i in range(min_val, max_val):
        str_i = str(i)
        flg = True
        for s, c in rule_dict.items():
          if str_i[s-1] == str(c):
            continue
          else:
            flg = False
            break
        if flg:
          return i
      return -1
     
     
    rule_dict = {}
     
    n, m = map(int, input().split())
    res = -1
    for i in range(m):
      s, c = map(int, input().split())
      if c == 0 and s == 1:
        print(-1)
        sys.exit()
      if s not in rule_dict:
        rule_dict[s] = c
        continue
      current_c = rule_dict[s]
      if c != current_c:
        print(-1)
        sys.exit()
     
    print(get_minimun_val(n, rule_dict))

Fixed code:
import sys

def get_minimun_val(n, rule_dict):
  max_val = 10**n
  min_val = 10**(n-1)
  if min_val == 1:
    min_val=0
  for i in range(min_val, max_val):
    str_i = str(i)
    flg = True
    for s, c in rule_dict.items():
      if str_i[s-1] == str(c):
        continue
      else:
        flg = False
        break
    if flg:
      return i
  return -1


rule_dict = {}

n, m = map(int, input().split())
res = -1
for i in range(m):
  s, c = map(int, input().split())
  if c == 0 and s == 1 and n > 1:
    print(-1)
    sys.exit()
  if s not in rule_dict:
    rule_dict[s] = c
    continue
  current_c = rule_dict[s]
  if c != current_c:
    print(-1)
    sys.exit()

print(get_minimun_val(n, rule_dict))
Buggy code:
N, M = map(int, input().split())

ans = []
neg = 0
for n in range(N):
  ans.append(-1)

print(ans)

for m in range(M):
  s, c = map(int, input().split())
  if ans[s-1] == -1:
    ans[s-1] = c
  elif ans[s-1] == c:
    pass
  else:
    neg = -1
    break

print(ans)

for j in range(len(ans)):
  if ans[j] == -1:
    ans[j] = 0

if N == 1:
  pass
elif ans[0] == 0:
  ans[0] = 1

if neg == -1:
  print(neg)
else:
  print("".join([str(i) for i in ans]))

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

ans = []
neg = 0
for n in range(N):
  ans.append(-1)

for m in range(M):
  s, c = map(int, input().split())
  if ans[s-1] == -1:
    ans[s-1] = c
  elif ans[s-1] == c:
    pass
  else:
    neg = -1
    break

if ans[0] == 0 and N != 1:
  neg = -1

for j in range(len(ans)):
  if ans[j] == -1:
    ans[j] = 0

if N == 1:
  pass

elif ans[0] == 0:
  ans[0] = 1

if neg == -1:
  print(neg)
else:
  print("".join([str(i) for i in ans]))
Buggy code:
n,m = map(int,input().split())
digit = ['-2']*n
for i in range(m):
    s,c = input().split()
    s = int(s)
    if digit[s-1] == '-2' or digit[s-1] == c:
        digit[s-1] = c
    else:
        digit[s-1] = '-1'
if ('-1' in digit) or (len(digit)!=1 and digit[0] == '0'):
    print(-1)
else:
    print("".join(digit.replace('-2','0')))

Fixed code:
n,m = map(int,input().split())
digit = ['-2']*n
for i in range(m):
    s,c = input().split()
    s = int(s)
    if digit[s-1] == '-2' or digit[s-1] == c:
        digit[s-1] = c
    else:
        digit[s-1] = '-1'
if ('-1' in digit) or (len(digit)!=1 and digit[0] == '0'):
    print(-1)
else:
    if digit[0] != '-2' or (len(digit)==1 and digit[0] == '-2'):
        print("".join(digit).replace('-2','0'))
    else:
        digit[0] = '1'
        print("".join(digit).replace('-2','0'))
Buggy code:
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]



for i in range(10**n):
    ans = str(i)
    if len(i) == n and all([i[s[j]-1] == str(c[j]) for j in range(m)]):
        print(ans)
        exit()
print(-1)

Fixed code:
# n,m = map(int, input().split())
# sc = [map(int, input().split()) for _ in range(m)]
# s, c = [list(i) for i in zip(*sc)]
#
#
#
# for i in range(10**n):
#     ans = str(i)
#     if len(i) == n and all([i[s[j]-1] == str(c[j]) for j in range(m)]):
#         print(ans)
#         exit()
#
#
# print(-1)

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

s, c = [], []
for _ in range(m):
    s_, c_ = map(int, input().split())
    s.append(s_)
    c.append(c_)

for i in range(10 ** n):
    ans = str(i)
    if len(ans) == n and all([ans[s[j] - 1] == str(c[j]) for j in range(m)]):
        print(ans)
        exit()

print(-1)
Buggy code:
N,M = map(int, input().split())
s1 = []
s2 = []
flg = True
for i in range(M):
  n1,n2 = map(int,input().split())
  s1.append(n1)
  s2.append(n2)
for i in range(1000):
  flg = True
  num = [int(x) for x in list(str(i))]
  if len(num) == N:
    for j in range(M):
      if s2[j] != num[s1[j] - 1]:
        flg = False
    if flg:
      print(s2)
      print(i)
      print(num)
      exit()
if flg == False:
  print(-1)

Fixed code:
N,M = map(int, input().split())
s1 = []
s2 = []
flg = True
for i in range(M):
  n1,n2 = map(int,input().split())
  s1.append(n1)
  s2.append(n2)
for i in range(1000):
  flg = True
  num = [int(x) for x in list(str(i))]
  if len(num) == N:
    for j in range(M):
      if s2[j] != num[s1[j] - 1]:
        flg = False
    if flg:
      print(i)
      exit()
print(-1)
Buggy code:
import sys
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

ans = [-1] * n
for i in sc:
    s,c=sc[i]
    if (ans[s-1] == c) | (ans[s-1] == -1):
        ans[s-1] = c
    else:
        print(-1)
        sys.exit()

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

if n != 1:
    if ans[0] == 0:
        print(-1)
        sys.exit()

print(*ans, sep='')


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

ans = [-1] * n
for i in sc:
    s, c = i
    if (ans[s-1] == c) | (ans[s-1] == -1):
        ans[s-1] = c
    else:
        print(-1)
        sys.exit()

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

if n != 1:
    if ans[0] == 0:
        print(-1)
        sys.exit()

print(*ans, sep='')
Buggy code:
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())
k=["0"]*n
if m==0 and n==1:
    print(0)
elif m==0 and n!=1:
    print(10**(n-1))
else:
    for i in range(m):
        if k[s[i]-1]=="0":
            k[s[i]-1]=c[i]
        elif k[s[i]-1]==c[i]:
            k[s[i]-1]=c[i]
        else:
            print(-1)
            break

    else:
        t=0
        if k[0]=="0":
            k[0]=1
        for i in range(n):
            t=t+10**(n-1-i)*int(k[i])
        print(t)

Fixed code:
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())
k=["0"]*n
if m==0 and n==1:
    print(0)
elif m==0 and n!=1:
    print(10**(n-1))
else:
    for i in range(m):
        if k[s[i]-1]=="0":
            k[s[i]-1]=c[i]
        elif k[s[i]-1]==c[i]:
            k[s[i]-1]=c[i]
        else:
            print(-1)
            break

    else:
        t=0
        if k[0]=="0":
            k[0]=1
        if k[0]==0 and n==1:
            print(0)
        elif k[0]==0 and n!=1:
            print(-1)
        else:
            for i in range(n):
                t=t+10**(n-1-i)*int(k[i])
            print(t)
Buggy code:
N, M = map(int, input().split())
num = ['']*N
valid = True
#create number from input
for i in range(M):
  s, c = map(int, input().split())
  if (num[s-1] == ''):
    num[s-1] = c
  elif (num[s-1] != c):
    valid = False
    break
#check whether 0 is at front
if (N > 1):
  if (num[0]==0):
    valid = False
  
if valid:
  first = True
  #fill the blank parts
  if (num[0]==''):
    num[0]==1
  for i in range(1,N):
    num[i] = 1
  #convert list to number
  answer = 0
  for i in range(N):
    answer *= 10
    answer += num[i]
  print(answer)
else:
  print(-1)


Fixed code:
N, M = map(int, input().split())
num = ['']*N
valid = True
#create number from input
for i in range(M):
  s, c = map(int, input().split())
  if (num[s-1] == ''):
    num[s-1] = c
  elif (num[s-1] != c):
    valid = False
    break
#check whether 0 is at front
if (N > 1):
  if (num[0]==0):
    valid = False
  
if valid:
  #fill the blank parts
  for i in range(N):
    if (num[i] == ''):
      if (i == 0):
        if (N == 1):
          num[i] = 0
        else:
          num[i] = 1
      else:
      	num[i] = 0
  #convert list to number
  answer = 0
  for i in range(N):
    answer *= 10
    answer += num[i]
  print(answer)
else:
  print(-1)
Buggy code:
n,m = map(int,input().split())
t = [[] for _ in range(n)]
for i in range(m):
    t_1,t_2 = map(int,input().split())
    t[t_1-1].append(t_2)

ans = ""
for i in range(n):
    if len(set(t[i])) == 1:
        ans += str(t[i][0])
    if not t[i]:
        if i == 0:
            ans += "1"
        else:
            ans += "0"
if ans[0] == "0":
    if n == 1:
        print(0)
    else:
        print(-1)
else:
    print(ans)


Fixed code:
n,m = map(int,input().split())
t = [[] for _ in range(n)]
for i in range(m):
    t_1,t_2 = map(int,input().split())
    t[t_1-1].append(t_2)

ans = ""
for i in range(n):
    if len(set(t[i])) == 1:
        ans += str(t[i][0])
    elif not t[i]:
        if i == 0:
            if n == 1:
                ans += "0"
            else:    
                ans += "1"
        else:
            ans += "0"
    else:
        print(-1)
        exit()
if ans[0] == "0":
    if n == 1:
        print(0)
    else:
        print(-1)
else:
    print(ans)
Buggy code:
N, M = map(int, input().split())

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

for i in range(1000):
    str_i = str(i)
    if len(str_i) != N:
        break

    for sc in SC:
        index = sc[0]-1

        if len(str_i) != N:
            break
        if str_i[index] != str(sc[1]):
            break
    else:
        print(i)
        exit(0)
print(-1)


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

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

for i in range(1000):
    str_i = str(i)
    if len(str_i) != N:
        continue

    for sc in SC:
        index = sc[0]-1

        if len(str_i) != N:
            break
        if str_i[index] != str(sc[1]):
            break
    else:
        print(i)
        exit(0)
print(-1)
Buggy code:
n,m = map(int,input().split())
l = [-1] * n
for i in range(m):
  s,c = map(int,input().split())
  if n != 1 and [s,c] == [1,0]:
    print(-1)
    exit()
  if l[s-1] == -1 or l[s-1] == c:
    l[s-1] = c
  else:
    print(-1)
    exit()
if l[0] == -1 and n != 1:
  l[0] = 1
else:
  l[0] = 0
print(*[i if i != -1 else 0 for i in l],sep='')

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