qyliang/CodeNanoFix huggingface dataset:
Buggy code:
"""
Created on Sun Mar  1 21:17:39 2020

@author: naoki
"""
import sys
N, M = map(int, input().split())
sc = [list(map(int,input().split())) for _ in range(M)]

#10**(N)
for num in range(10**(N)):
    switch = True
    for condition in sc:
        if len(list(str(num))) >= condition[0]:
            #print(list(str(num)), condition[1])
            if list(str(num))[condition[0]-1] == str(condition[1]):
                #print(num, condition[0], condition[1])
                continue
            else:
                switch = False
        else:
            switch = False
    if switch == True:
        print(num)
        sys.exit()

print(-1)

Fixed code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  1 21:17:39 2020

@author: naoki
"""
import sys
N, M = map(int, input().split())
sc = [list(map(int,input().split())) for _ in range(M)]

if N == 1 and M == 0:
    print(0)
    sys.exit()

for num in range(10**(N-1),10**(N)):
    switch = True
    for condition in sc:
        if len(list(str(num))) >= condition[0]:
            if list(str(num))[condition[0]-1] == str(condition[1]):
                continue
            else:
                switch = False
        else:
            switch = False
    if switch == True:
        print(num)
        sys.exit()

switch = True
if N == 1:
    for condition in sc:
        if condition[0] == 1 and condition[1] == 0:
            continue
        else:
            switch = False
    if switch == True:
        print(0)
        sys.exit()

print(-1)
Buggy code:
n, m = map(int, input().split())
sc = {}
for m2 in range(m):
    sc[m2]=input().split()
ok_list= []
ok_list= []
for al in range(10**(n-1), 10**(n)):
    ynli = []
    li = list(str(al))
    for mm in range(m):
        if li[int(sc[int(mm)][0])-1] != sc[int(mm)][1]:
            ynli.append("NO")
    if "NO" in ynli:
        pass
    else:
        ok_list.append(al)
print(min(ok_list))

Fixed code:
n, m = map(int, input().split())
sc = {}
for m2 in range(m):
    sc[m2]=input().split()
ok_list= []
for al in range(0, 10**(n)):
    ynli = []
    li = list(str(al))
    if len(li) == n:
        for mm in range(m):
            if li[int(sc[int(mm)][0])-1] != sc[int(mm)][1]:
                ynli.append("NO")
        if "NO" in ynli:
            pass
        else:
            ok_list.append(al)
    else:
        pass
if ok_list == []:
    print(-1)
else:
    print(min(ok_list))
Buggy code:
n, m = map(int, input().split())
res = ['-1' for i in range(n)]
f = 1
for _ in range(m):
    s, c = map(int, input().split())
    if res[s-1] == '-1' or res[s-1] == str(c):
        res[s-1] = str(c)
    else:
        f = 0
if not f:
    print(-1)
    exit()
for i in range(n):
    if res[i] == '-1':
        if i != 0:
            res[i] = '0'
        else:
            res[i] = '1'
if res[0] == '0' and n != 1:
    res[0] = '1'
elif res[0] == '0' and n == 1:
    print(res[0])
    exit()
print(''.join(res))

Fixed code:
n, m = map(int, input().split())
res = ['-1' for i in range(n)]
f = 1
for _ in range(m):
    s, c = map(int, input().split())
    if res[s-1] == '-1' or res[s-1] == str(c):
        res[s-1] = str(c)
    else:
        f = 0
if not f:
    print(-1)
    exit()
if res[0] == '0' or res[0] == '-1':
    if n == 1:
        print(0)
        exit()
    else:
        if res[0] == '0':
            print(-1)
            exit()
        else:
            res[0] = '1'
for i in range(1, n):
    if res[i] == '-1':
        res[i] = '0'
print(''.join(res))
Buggy code:
N, M = map(int, input().split())
Q = [list(map(int, input().split())) for i in range(M)]


for n in range(1000):
    X = list(map(int, list(str(n))))
    for s, c in Q:
        s -= 1
        if len(X) <= s:
            break

        if X[s] != c:
            break
    else:
        print(n)
        exit()

print(-1)


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


for n in range(1000):
    X = list(map(int, list(str(n))))
    if len(X) != N:
        continue
    for s, c in Q:
        s -= 1

        if X[s] != c:
            break
    else:
        print(n)
        exit()

print(-1)
Buggy code:

if __name__ == '__main__':
    N, M = map(int, input().split())
    S = []
    C = []

    for i in range(M):
        s, c = map(int, input().split())
        s -= 1
        S.append(s)
        C.append(c)

    for num in range(pow(10, N-1), pow(10, N)):
        st_num = str(num)
        cnt = 0
        for m in range(M):
            if int(st_num[S[m]])==C[m]:
                cnt += 1
        if cnt==M:
            #print(st_num)
            quit()
    print(-1)

Fixed code:
if __name__ == '__main__':
    N, M = map(int, input().split())
    S = []
    C = []

    for i in range(M):
        s, c = map(int, input().split())
        s -= 1
        S.append(s)
        C.append(c)

    for num in range(0, pow(10, N)):
        st_num = str(num)
        if len(str(st_num))!=N: continue
        cnt = 0
        for m in range(M):
            if int(st_num[S[m]])==C[m]:
                cnt += 1
        if cnt==M:
            print(st_num)
            quit()
    print(-1)
Buggy code:
n,m = map(int,input().split())
s=[0]*m
c=[0]*m
ans=[]
judge=False
for i in range(m):
    s[i],c[i]=map(int,input().split())
for j in range(10**n):
    j=str(j)
    for l in range(m):
        if int(j[s[l]-1])==c[l]:
            pass
        else:
            break
    else:
        ans.append(int(j))
        judge=True
if judge:
    print(min(ans))
else:
    print('-1')

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())
ans=[]
judge=False
if n ==1:
    for j in range(10):
        j = str(j)
        for l in range(m):
            if int(j[s[l]-1])==c[l]:
                pass
            else:
                break
        else:
            ans.append(int(j))
            judge=True

else:
    for j in range(10**(n-1),10**n):
        j=str(j)
        for l in range(m):
            if int(j[s[l]-1])==c[l]:
                pass
            else:
                break
        else:
            ans.append(int(j))
            judge=True
if judge:
    print(min(ans))
else:
    print('-1')
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.appemd(b)
found=False
start=pow(10,N-1)
stop=pow(10,N)
if N==1:
    start=0
for i in range(start,stop):
    i_str=str(i)
    passed=True
    for j in range(M):
        if not i_str[s[j]-1]==str(c[j]):
            passed=False
            break
    if passed:
        found=False
        print(i)
        break
if not found:
    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)
found=False
start=pow(10,N-1)
stop=pow(10,N)
if N==1:
    start=0
for i in range(start,stop):
    i_str=str(i)
    passed=True
    for j in range(M):
        if not i_str[s[j]-1]==str(c[j]):
            passed=False
            break
    if passed:
        found=True
        print(i)
        break
if not found:
    print('-1')
Buggy code:
n,m = map(int,input().split())
query = [list(map(int,input().split())) for _ in range(m)]
for i in range(10**n):
    k = str(i)
    flag = True
    for s,c in query:
        if k[s-1] != c:
            flag = False
    if flag and len(k) == n:
        print(i)
        exit()
print(-1)

Fixed code:
n,m = map(int,input().split())
query = [list(map(int,input().split())) for _ in range(m)]
if n == 1:
    for i in range(10):
        k = str(i)
        flag = True
        for s,c in query:
            if int(k) != c:
                flag = False
        if flag:
            print(i)
            exit()
else:
    for i in range(10**(n-1),10**n):
        k = str(i)
        flag = True
        for s,c in query:
            if k[s-1] != str(c):
                flag = False
        if flag and len(k) == n:
            print(i)
            exit()
print(-1)
Buggy code:
n,m = map(int,input().split())
if m == 0:
    if n == 1:
        print(0)
        exit()
    if n == 2:
        print(10)
        exit()
    if n == 3:
        print(100)
        exit()
a = [-1]*n
for _ in range(m):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and n == 3:
        print(-1)
        exit()
    if s == 1 and c == 0 and n == 2:
        print(-1)
        exit()
    if a[s-1] == -1:
        a[s-1] = c
    else:
        if a[s-1] != c:
            print(-1)
            exit()

ans = ""
for i in range(n):
    if a[i] == -1:
        if i == 0 or i == 1:
            ans += "1"
        else:
            ans += "0"
    else:
        ans += str(a[i])
#print(ans)
if ans[0] == "0" and n > 1:
    print(-1)
else:
    print(ans)

Fixed code:
n,m = map(int,input().split())
if m == 0:
    if n == 1:
        print(0)
        exit()
    if n == 2:
        print(10)
        exit()
    if n == 3:
        print(100)
        exit()

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

ans = ""
for i in range(n):
    if a[i] == -1:
        if i == 0:
            ans += "1"
        else:
            ans += "0"
    else:
        ans += str(a[i])
print(ans)
Buggy code:
N, M = list(map(int,input().split()))
s = []
c = []
for i in range(M):
    in1, in2 = list(map(int,input().split()))
    s.append(in1 - 1)
    c.append(in2)
    
if M > N:
    print(-1)
else:
    solve()
    
def solve():
    
    res = [-1 for _ in range(N)]

    for i in range(M):
        if res[s[i]] != -1 and res[s[i]] != c[i]:
            print(-1)
            return
        res[s[i]] = c[i] 

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

Fixed code:
N, M = list(map(int,input().split()))
s = []
c = []
for i in range(M):
    in1, in2 = list(map(int,input().split()))
    s.append(in1 - 1)
    c.append(in2)
    
def solve():
    
    res = [-1 for _ in range(N)]

    for i in range(M):
        if res[s[i]] != -1 and res[s[i]] != c[i]:
            print(-1)
            return
        if s[i] == 0 and c[i] == 0 and N != 1:
            print(-1)
            return
        res[s[i]] = c[i] 

    ans = ""
    
    if N == 1:
        if res[0] == -1:
            print(0)
        else:
            print(res[0])
        return
    
    for i in range(N):
        if res[i] == -1:
            if i == 0:
                ans += "1"
            else:
                ans += "0"
        else:
            ans += str(res[i])
    print(ans)

solve()
Buggy code:
import sys

N, M = map(int, input().split())

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

for i in range(10**(N-1)-1, 10**N):
  tes = str(i)
  flag = True
  for s, c in zip(S, C):
    if tes[s-1] != str(c):
      flag = False
  if flag:
    print(tes)
    sys.exit()

print(-1)

Fixed code:
import sys

N, M = map(int, input().split())

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

for i in range(10**N):
  tes = str(i)

  if len(tes) != N:
    continue
  
  flag = True
  for s, c in zip(S, C):
    if tes[s-1] != str(c):
      flag = False
  if flag:
    print(tes)
    sys.exit()


print(-1)
Buggy code:
n, m = map(int, input().split())
s = []
c = []
number = 100000
for i in range(m):
    x, y = map(int, input().split())
    s = s + [x]
    c = c + [str(y)]
for i in range(1000):
    count = 0
    i_list = list(str(i))
    if len(i_list) == n:
        for j in range(m):
            if i_list[s[j] - 1] != c[j]:
                count += 1
        if count == 0:
            number = i
            break
print(number)                 


Fixed code:
n, m = map(int, input().split())
s = []
c = []
number = 100000
for i in range(m):
    x, y = map(int, input().split())
    s = s + [x]
    c = c + [str(y)]
for i in range(1000):
    count = 0
    i_list = list(str(i))
    if len(i_list) == n:
        for j in range(m):
            if i_list[s[j] - 1] != c[j]:
                count += 1
        if count == 0:
            number = i
            break
if number < 10000:
    print(number)
else:
    print('-1')
Buggy code:
N, M = map(int, input().split())
r = list([None]*N)
for i in range(M):
    s, c = map(int, input().split())
    if r[s-1] is not None:
        print("-1")
        exit()
    r[s-1] = c

if N > 1 and r[0] == 0:
        print("-1")
        exit()

for i in range(len(r)):
    if r[i] is None:
        if N > 1 and i == 0:
            r[i] = 1
        else:
            r[i] = 0

print("".join(map(str, r)))

Fixed code:
N, M = map(int, input().split())
r = list([None]*N)
for i in range(M):
    s, c = map(int, input().split())
    if r[s-1] is not None and r[s-1] != c:
        print("-1")
        exit()
    r[s-1] = c

if N > 1 and r[0] == 0:
        print("-1")
        exit()

for i in range(len(r)):
    if r[i] is None:
        if N > 1 and i == 0:
            r[i] = 1
        else:
            r[i] = 0

print("".join(map(str, r)))
Buggy code:
n,m = map(int,input().split())

s_li=[0]*m
l_li=[0]*m
for i in range(m):
    s_li[i],l_li[i] = map(int,input().split())

for i in range(1000):
    string = str(i)
    if len(string)!=n:
        continue
    flag=True
    for j in range(m):
        if int(string[s_li[j]-1])==l_li[j]:
            continue
        flag=False
        break
    if flag:
        print(string);exit()
    




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

s_li=[0]*m
l_li=[0]*m
for i in range(m):
    s_li[i],l_li[i] = map(int,input().split())

for i in range(1000):
    string = str(i)
    if len(string)!=n:
        continue
    flag=True
    for j in range(m):
        if int(string[s_li[j]-1])==l_li[j]:
            continue
        flag=False
        break
    if flag:
        print(string);exit()
print(-1)
Buggy code:
N, M = map(int, input().split())
cond = [list(map(int, input().split())) for _ in range(M)]
flag = True
ans = [-1]*N

if M == 0:
    if N == 1:
        print(0)
    else:
        print('1'+'0'*(N-1))
else:
    for i in cond:
    digit = i[0]-1
    if digit > N-1:
        flag = False
        break
    elif ans[digit] != -1 and ans[digit] != i[1]:
        flag = False
        break
    elif i == [1, 0] and N > 1:
        flag = False
        break
    else:
        ans[digit] = i[1]

    if flag:
        if ans[0] == -1:
            ans[0] = 1
        
        for i in range(1, N):
            if ans[i] == -1:
                ans[i] = 0
        
        print(''.join(map(str, ans)))
    else:
        print(-1)

Fixed code:
N, M = map(int, input().split())
cond = [list(map(int, input().split())) for _ in range(M)]
flag = True
ans = [-1]*N

if M == 0:
    if N == 1:
        print(0)
    else:
        print('1'+'0'*(N-1))
else:
    for i in cond:
        digit = i[0]-1
        if digit > N-1:
            flag = False
            break
        elif ans[digit] != -1 and ans[digit] != i[1]:
            flag = False
            break
        elif i == [1, 0] and N > 1:
            flag = False
            break
        else:
            ans[digit] = i[1]

    if flag:
        if ans[0] == -1:
            ans[0] = 1
        
        for i in range(1, N):
            if ans[i] == -1:
                ans[i] = 0
        
        print(''.join(map(str, ans)))
    else:
        print(-1)
Buggy code:
N,M = input().split()
s,c,a = [],[],[]
number = []
for i in range(int(M)):
    a_i = input().split()
    a.append(a_i)
    s.append(int(a_i[0]))
    c.append(int(a_i[1]))
ans = True
for i in range(int(M)):
    number.append('')
for i in range(int(M)):
    if s[i]==1 and c[i]==0:
        print('-1')
        ans = False
    elif number[s[i]-1] == '' or number[s[i]-1] == c[i]:
        number[s[i]-1] = c[i]
    else:
        print('-1')
        ans = False
for i,elem in enumerate(number):
    if elem == '' and i == 0:
        number[i] = 1
    if elem == '':
        number[i] = 0
if ans:
    print(number)

Fixed code:
N,M = input().split()
s,c,a = [],[],[]
number = []
for i in range(int(M)):
    a_i = input().split()
    a.append(a_i)
    s.append(int(a_i[0]))
    c.append(int(a_i[1]))
ans = True
for i in range(int(N)):
    number.append('')
for i in range(int(M)):
    if s[i]==1 and c[i]==0 and int(N)>1:
        if ans:
            print('-1')
            ans = False
    elif s[i] > int(N):
        if ans:
            print('-1')
            ans = False
    elif number[s[i]-1] == '' or number[s[i]-1] == c[i]:
        number[s[i]-1] = c[i]
    else:
        if ans:
            print('-1')
            ans = False
for i,elem in enumerate(number):
    if number[i] == '' and i == 0 and int(N) >1:
        number[i] = 1
    elif elem == '':
        number[i] = 0
if ans:
    strs = '' 
    for i in number:
        strs += str(i)
    print(int(strs))
Buggy code:
N, M = [int(i) for i in input().split()]
v = ['x' for n in range(N)]
e = False
for m in range(M):
    s, c = [int(i) for i in input().split()]
    if e:
        continue
    if v[s-1] != 'x' and v[s-1]!=str(c):
        e = True
    else:
        v[s-1] = str(c)

if e:
    print(-1)
    exit()

r = []
fd = True
for d in v:
    if d == 'x':
        if fd:
            r.append('1')
        else:
            r.append('0')
    else:
        r.append(d)
    fd = False

rv = int("".join(r))

if len(str(rv))!=N:
    print("".join(r))
    print(-1)
else:
    print("".join(r))

Fixed code:
N, M = [int(i) for i in input().split()]
v = ['x' for n in range(N)]
e = False
for m in range(M):
    s, c = [int(i) for i in input().split()]
    if e:
        continue
    if v[s-1] != 'x' and v[s-1]!=str(c):
        e = True
    else:
        v[s-1] = str(c)

if e:
    print(-1)
    exit()

r = []
fd = N != 1
for d in v:
    if d == 'x':
        if fd:
            r.append('1')
        else:
            r.append('0')
    else:
        r.append(d)
    fd = False

rv = int("".join(r))

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

Fixed code:
n,m = map(int,input().split())
ans = [-1 for i in range(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 and ans[s-1] != str(c):
    print(-1)
    exit()
  ans[s-1] = str(c)
for i in range(n):
  if ans[i] == -1:
    if i == 0 and n != 1:
      ans[0] = "1"
    else:
      ans[i] = "0"
print(int("".join(ans)))
Buggy code:
N,M = map(int,input().split())
ans = [-1]*N
flg = 0
flg2 = 0

for i in range(M):
  s,c = map(int, input().split())
  s -= 1
  if ans[s] == -1 or ans[s] == c:
    ans[s] = c
  else:
    flg = 1
  
if flg == 0:
  if N == 1 and ans[0] == -1:
    print("0")
  elif ans[0] == 0:
    print("-1")
  else:
    for i in range(N):
      if ans[i] == -1:
        ans[i] = 0
      else:
        flg2 = i
    for i in range(flg2):
      ans[i] = ""
    print(int("".join(map(str,ans))))
else:
  print("-1")

Fixed code:
N,M = map(int,input().split())
ans = [-1]*N
flg = 0
 
for i in range(M):
  s,c = map(int, input().split())
  s -= 1
  if ans[s] == -1 or ans[s] == c:
    ans[s] = c
  else:
    flg = 1
  
if flg == 0:
  if N == 1 and ans[0] == -1 or N == 1 and ans[0] == 0:
    print("0")
  elif ans[0] == 0:
    print("-1")
  else:
    if ans[0] == -1:
      ans[0] = 1
    for i in range(1,N):
      if ans[i] == -1:
        ans[i] = 0
    print(int("".join(map(str,ans))))
else:
  print("-1")
Buggy code:
n,m=map(int,input().split())
l=["0"]*n
n,m=map(int,input().split())
l=["0"]*n
f=[0]*n
frag=0
for i in range(m):
    s,c=map(int,input().split())
    if f[s-1]==0 or l[s-1]==str(c):
        l[s-1]=str(c)
        f[s-1]=1
    else:
        frag=1
        break
if frag==1 or (l[0]=="0" and n!=1):
    print(-1)
else:
    for j in l:
        
        print(j,end="")

Fixed code:

n,m=map(int,input().split())
l=["0"]*n
l[0]="1"
l[-1]="0"
f=[0]*n
frag=0
for i in range(m):
    s,c=map(int,input().split())
    if f[s-1]==0 or l[s-1]==str(c):
        l[s-1]=str(c)
        f[s-1]=1
    else:
        frag=1
        break
if frag==1 or (l[0]=="0" and n!=1):
    print(-1)
else:
    for j in l:
        print(j,end="")
Buggy code:
N,M=map(int,input().split())
SC=[list(map(int,input().split())) for i in range(M)]
begin=10**N-1
end=10**N
if N==1:
  print(SC[0][1])
for i in range(begin,end):
  i=str(i)
  for s,c in SC:
    if i[s-1]!=c:
      break
  else:
    print(i)
    exit()
print(-1)

Fixed code:
N,M=map(int,input().split())
SC=[list(map(int,input().split())) for i in range(M)]
begin=10**(N-1)
end=10**N
if N==1:
  begin=0
for i in range(begin,end):
  i=str(i)
  for s,c in SC:
    if i[s-1]!=str(c):
      break
  else:
    print(i)
    exit()
print(-1)
Buggy code:
N, M = map(int, input().split())
l = []
for i in range(N):
    l.append(10)

f = True
for _ in range(M):
    a, b = map(int, input().split())
    a-=1
    if l[a]==b:
        continue
    elif l[a]==10:
        l[a]=b
    else:
        print(-1)
        exit()

if M==0:
    print(0) if N==1 else print(10**(N-1))
elif l[0]==0:
    print(0) if M==1 else print (-1)
else:
    for i in range(N):
        if l[i]==10:l[i]=0
        print(str(l[i]),end="")









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

f = True
for _ in range(M):
    a, b = map(int, input().split())
    a-=1
    if l[a]==b:
        continue
    elif l[a]==10:
        l[a]=b
    else:
        print(-1)
        exit()

if l[0]==0:
    print(0) if N==1 else print (-1)
else:
    if l[0]==10:
        if N==1:
            l[0]=0
        else:l[0]=1
    for i in range(0,N):
        if l[i]==10:l[i]=0
        print(str(l[i]),end="")
Buggy code:
N, M = list(map(int, input().split(' ')))
r = [ None for i in range(N) ]

duplicated = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None:
    duplicated = True
    break
  r[s-1] = c

v = -1
if not duplicated:
  for i in range(N):
    if r[i] is None:
      r[i] = 0
  v = sum(r[i] * 10**i for i in range(N))
  if v != 0 and v < 10**(N-1):
    v = -1

print(v)


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

illegal = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None and r[s-1] != c:
    illegal = True
    break
  r[s-1] = c

v = -1
if not illegal:
  for i in range(N):
    if r[i] is None:
      if i == 0 and N != 1:
        r[i] = 1
      else:
        r[i] = 0
  v = sum(r[i] * 10**(N-1-i) for i in range(N))
  if v < 10**(N-1) and not (N == 1 and v == 0):
    v = -1

print(v)
Buggy code:
N,M=map(int,input().split())
flag = True
res = ""
List = []
for i in range (M):
  List.append(list(map(int, input().split())))
resList = ["10"]*N
for i in range(M):
  if resList[List[i][0]-1] == "10":
    resList[List[i][0]-1] = str(List[i][1])
  else:
    if resList[List[i][0]-1] != str(List[i][1]):
      flag = False
if resList[0] == 0:
  flag = False
if flag:
  for i in range(N):
    if resList[i] == "10":
      res += "1"
    else:
      res += resList[i]
  print(int(res))
else:
  print(-1)

Fixed code:
N,M=map(int,input().split())
flag = True
res = ""
List = []
for i in range (M):
  List.append(list(map(int, input().split())))
resList = ["10"]*N
for i in range(M):
  if resList[List[i][0]-1] == "10":
    resList[List[i][0]-1] = str(List[i][1])
  else:
    if resList[List[i][0]-1] != str(List[i][1]):
      flag = False
if resList[0] == "0":
  flag = False
elif resList[0] == "10" and N > 1:
  resList[0]="1"
elif resList[0] == "10" and N == 1:
  resList[0]="0"
  flag = False
if flag:
  for i in range(N):
    if resList[i] == "10":
      res += "0"
    else:
      res += resList[i]
  print(int(res))
else:
  if resList[0] == "0" and N ==1:
    print(0)
  else:
    print(-1)