qyliang/CodeNanoFix huggingface dataset:
Buggy code:
# input
N, M = map(int, input().split())
s = [0]*M
c = [0]*M

if(M==0 and N==1):
    print("0")
elif(M==0 and N>1):
    ans_print = "1"
    for i in range(N-1):
        ans_print += "0"
    print(ans_print)
else:
    for i in range(M):
        s[i], c[i] = map(int, input().split())

    ans = [-1]*N
    b = True

    for i in range(M):
        if(ans[s[i]-1] != -1 and ans[s[i]-1] != c[i]):
            b = False
        else:
            ans[s[i]-1] = c[i]

    for i in range(len(ans)):
        if(i==0):
            ans[i] = 1
        elif(ans[i] == -1):
            ans[i] = 0
    
    if(N>1 and ans[0]==0):
        b = False
        
    if(b):
        ans_print = ""
        for i in range(len(ans)):
            ans_print += str(ans[i])
        print(ans_print)
    else:
        print("-1")

Fixed code:
# input
N, M = map(int, input().split())
s = [0]*M
c = [0]*M

if(M==0 and N==1):
    print("0")
elif(M==0 and N>1):
    ans_print = "1"
    for i in range(N-1):
        ans_print += "0"
    print(ans_print)
else:
    for i in range(M):
        s[i], c[i] = map(int, input().split())

    ans = [-1]*N
    b = True

    for i in range(M):
        if(ans[s[i]-1] != -1 and ans[s[i]-1] != c[i]):
            b = False
        else:
            ans[s[i]-1] = c[i]

    for i in range(len(ans)):
        if(i==0 and ans[i]==-1):
            ans[i] = 1
        elif(ans[i] == -1):
            ans[i] = 0
    
    if(N > 1 and ans[0]==0):
        b = False
        
    if(b):
        ans_print = ""
        for i in range(len(ans)):
            ans_print += str(ans[i])
        print(ans_print)
    else:
        print("-1")
Buggy code:
import collections

N,M=map(int,input().split())
#if not(M==0):
s=[list(map(int,input().split())) for _ in range(M)]
flag=1
l=[[i+1,-1] for i in range(N)]
ns=""
#print(l)
"""
if M==0:
    for i in range(M):
        if i==0:
            l[i][1]=1
        else:
            l[i][1]=0
        ns="".join((ns,str(l[i][1])))
    print(ns)
"""
#else:
for i in range(M):
    #print(l)
    if l[s[i][0]-1][1]==-1:
        l[s[i][0]-1][1]=s[i][1]
    else:
        if not(l[s[i][0]-1][1]==s[i][1]):
            flag=0
if (not(N==1) and (l[0][1]==0)):
    flag=0
if flag==1:
    for i in range(N):
        if not(N==1)and(l[i][1]==-1):
            if i==0:
                l[i][1]=1
            else:
                l[i][1]=0
        else:
            l[i][1]=0
        ns="".join((ns,str(l[i][1])))
    print(ns)
else:
    print("-1")



Fixed code:
import collections

N,M=map(int,input().split())
#if not(M==0):
s=[list(map(int,input().split())) for _ in range(M)]
flag=1
l=[[i+1,-1] for i in range(N)]
ns=""
#print(l)
"""
if M==0:
    for i in range(M):
        if i==0:
            l[i][1]=1
        else:
            l[i][1]=0
        ns="".join((ns,str(l[i][1])))
    print(ns)
"""
#else:
for i in range(M):
    #print(l)
    if l[s[i][0]-1][1]==-1:
        l[s[i][0]-1][1]=s[i][1]
    else:
        if not(l[s[i][0]-1][1]==s[i][1]):
            flag=0
if (not(N==1) and (l[0][1]==0)):
    flag=0
if flag==1:
    for i in range(N):
        if not(N==1):
            if (l[i][1]==-1):
                if i==0:
                    l[i][1]=1
                else:
                    l[i][1]=0
        else:
            if (l[i][1]==-1):
                l[i][1]=0
        ns="".join((ns,str(l[i][1])))
    print(ns)
else:
    print("-1")
Buggy code:
n,m = map(int, input().split())
nums = [-1]*n
for _ in range(m):
  s,c = map(int, input().split())
  s = int(s)-1
  if nums[s] != -1 and nums[s] != c:
    print(-1)
    exit()
  nums[s] = c
  
for i in range(n):
  if nums[i] == -1:
    if i == 0:
      if n == 1:
        nums[0] = 0
      else:
        nums[0] = 1
    else:
      nums[i] = 0
ans = ""
for i in nums:
  ans += str(i)
print(ans)

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

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

t = 0
for i in p:
  t += int(i)

if len(str(t)) == n:
  print(int(t))
else:
  print(-1)

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

p = [-1]*n
for i in range(m):
  s,c = map(int, input().split())
  s -= 1
  if p[s] != -1 and p[s] != c:
    print(-1)
    exit()
  p[s] = c
  
if n != 1:
  if p[0] == -1:
    p[0] = 1
  for i in range(1, n):
    if p[i] == -1:
      p[i] = 0
else:
  if p[0] == -1:
    p[0] = 0
    
t = ''
for i in p:
  t += str(i)
t = int(t)

if len(str(t)) == n:
  print(t)
else:
  print(-1)
Buggy code:
# n = int(input())
n, m = map(int,input().split())
# l = [[0 for _ in range(n)] for _ in range(n)]
l = []
f = 0

for i in range(m):
    l.append(list(map(int,input().split())))

# print(l)

for i in range(1000):
    si = str(i)
    if len(si) == n:
        for j in range(m):
            print(si, l)
            if si[l[j][0]-1] == str(l[j][1]):
                print('OK')
                f = 0
            else:
                f = 1
                break
    else:
        continue
    if f == 0:
        print(si)
        exit()

print(-1)

Fixed code:
# n = int(input())
n, m = map(int,input().split())
# l = [[0 for _ in range(n)] for _ in range(n)]
l = []
f = 0

for i in range(m):
    l.append(list(map(int,input().split())))

# print(l)

for i in range(1000):
    si = str(i)
    if len(si) == n:
        for j in range(m):
            # print(si, l)
            if si[l[j][0]-1] == str(l[j][1]):
                # print('OK')
                f = 0
            else:
                f = 1
                break
    else:
        continue
    if f == 0:
        print(si)
        exit()

print(-1)
Buggy code:
import sys
input = sys.stdin.readline

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


Fixed code:
import sys
input = sys.stdin.readline

n,m = map(int,input().split())
L=[-1]*n
if n==1 and m==0:
    print(0)
    sys.exit()
for i in range(m):
    s,c=map(int,input().split())
    s-=1
    if L[s]==-1 or L[s]==c:
        L[s] = c
    else:
        print(-1)
        sys.exit()
if L[0]==0 and n>1:
    print(-1)
    sys.exit()
    
for i in range(n):
    if L[i]==-1:
        if i==0:
            L[i]=1
        else:
            L[i]=0
print(*L,sep="")
Buggy code:
#157
def main():
    N, M = map(int,input().split())
    num = [-1]*N
    for i in range(M):
        s, c = map(int,input().split())
        if(s==1 and c==0 and N!=1):
            print(-1)
            return
        if(num[s-1]==-1 or num[s-1]==c):
            num[s-1] = c
        else:
            print(-1)
            return
    result = ''
    for i in ramge(N):
        if(num[i]!=-1):
            result+=str(num[i])
        else:
            if(N==1):
                result+='0'
            elif(i==0):
                result+='1'
            else:
                result+='0'
    print(result)

main()

Fixed code:
#157
def main():
    N, M = map(int,input().split())
    num = [-1]*N
    for i in range(M):
        s, c = map(int,input().split())
        if(s==1 and c==0 and N!=1):
            print(-1)
            return
        if(num[s-1]==-1 or num[s-1]==c):
            num[s-1] = c
        else:
            print(-1)
            return
    result = ''
    for i in range(N):
        if(num[i]!=-1):
            result+=str(num[i])
        else:
            if(N==1):
                result+='0'
            elif(i==0):
                result+='1'
            else:
                result+='0'
    print(result)

main()
Buggy code:
N,M = map(int,input().split())
t = [-1]*N
for i in range(M):
    s, c=map(int, input().split())
    s -= 1
    if t[s] != c:
        print(-1)
        exit()
    t[s] = c
if N != 1:
    if t[0] == 0:
        print(-1)
        exit()
    if t[0] == -1:
        t[0] =1
    for i in range(1,N):
        if t[i] == -1:
            t[i] = 0
else:
    if t[0] == -1:
        t[0] = 0
print("".join(map(str,t)))
        


Fixed code:
N,M = map(int,input().split())
t = [-1]*N
for i in range(M):
    s, c=map(int, input().split())
    s -= 1
    if t[s] != -1 and t[s] != c:
        print(-1)
        exit()
    t[s] = c
if N != 1:
    if t[0] == 0:
        print(-1)
        exit()
    if t[0] == -1:
        t[0] =1
    for i in range(1,N):
        if t[i] == -1:
            t[i] = 0
else:
    if t[0] == -1:
        t[0] = 0
print("".join(map(str,t)))
Buggy code:
N,M = map(int,input().split())
N_list = [0]*N
flg_list  = [0]*N
flg = False
for i in range(M):
    s,c = map(int,input().split())
    if flg_list[s-1] == 0:
        N_list[s-1] = c
        flg_list[s-1] = 1
    elif N_list[s-1] != c:
        flg = True
        break
res = 0
for i in range(N-1,-1,-1):
    res += 10**i * N_list[N-1-i]

if N = 1:
    print(res)
elif flg or (N_list[0] == 0 and flg_list[0] == 1):
    print("-1")
elif N == len(str(res)):
    print(res)
else:
    print(res+10**(N-1))


Fixed code:
N,M = map(int,input().split())
N_list = [0]*N
flg_list  = [0]*N
flg = False
for i in range(M):
    s,c = map(int,input().split())
    if flg_list[s-1] == 0:
        N_list[s-1] = c
        flg_list[s-1] = 1
    elif N_list[s-1] != c:
        flg = True
        break
res = 0
for i in range(N-1,-1,-1):
    res += 10**i * N_list[N-1-i]

if N == 1 and not flg:
    print(res)
elif flg or (N_list[0] == 0 and flg_list[0] == 1):
    print("-1")
elif N == len(str(res)):
    print(res)
else:
    print(res+10**(N-1))
Buggy code:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep  7 17:11:27 2020

@author: liang
"""

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

ans = [-1]*N
res = 0
for i in range(M):
    s, c = map(int, input().split())
    if ans[s-1] == -1 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print(-1)
        break
else:
    if ans[0] == -1:
        ans[0] = 1
    ans = [0 if a == -1 else a for a in ans]
    #print(ans)
    for i in range(N):
        res += ans[-(i+1)]*10**i
    print(res)

Fixed code:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep  7 17:11:27 2020

@author: liang
"""

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

ans = [-1]*N
res = 0
for i in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and N != 1:
        print(-1)
        break
    if ans[s-1] == -1 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print(-1)
        break
else:
    if ans[0] == -1:
        ans[0] = 1
    if M == 0 and N == 1:
        ans[0] = 0
    ans = [0 if a == -1 else a for a in ans]
    #print(ans)
    for i in range(N):
        res += ans[-(i+1)]*10**i
    print(res)
Buggy code:
N, M = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(M)]
def cands(N):
    if N ==1:
        return range(10)
    else:
        return range(10 ** (N-1), 10 **N)

def main(N, sc):
    nums = cands(N)
    print(nums)
    for n in nums:
        try:
            for s,c in sc:
                assert(int(str(n)[s-1]) == c)
        except AssertionError as e:
            continue
        return n
    else:
        return -1
print(main(N, sc))

Fixed code:
N, M = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(M)]
def cands(N):
    if N ==1:
        return range(10)
    else:
        return range(10 ** (N-1), 10 **N)

def main(N, sc):
    nums = cands(N)
    for n in nums:
        try:
            for s,c in sc:
                assert(int(str(n)[s-1]) == c)
        except AssertionError as e:
            continue
        return n
    else:
        return -1
print(main(N, sc))
Buggy code:
n,m= map(int,input().split())
inputs = []
for _ in range(m):
    inputs.append(list(map(int,input().split())))

if n == 1:
    if len([i[1] for i in inputs if i[1] != inputs[0][1]]) > 1:
        print(-1)
        exit()
    else:
        print(max(0,inputs[0][1]))
else:
    out = [-1] * n
    for item in inputs:
        s = item[0]
        c = item[1]
        if out[s-1] != -1 and out[s-1] != c:
            print(-1)
            exit()
        else:
            out[s-1] = c

out[0] = max(out[0],1)
res = 0
for i in range(len(out)):
    if out[i] != -1:
        res += out[i] * 10 ** (n-i-1)
print(res)
        

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

if m == 0:
    if n == 1:
        print(0)
    else:
        print(10**(n-1))
    exit()
elif n == 1:
    if len([i[1] for i in inputs if i[1] != inputs[0][1]]) > 0:
        print(-1)    
    else:
        print(max(0,inputs[0][1]))
    exit()
else:
    out = [-1] * n
    for item in inputs:
        s = item[0]
        c = item[1]
        if out[s-1] != -1 and out[s-1] != c:
            print(-1)
            exit()
        elif s == 1 and c == 0:
            print(-1)
            exit()
        else:
            out[s-1] = c

out[0] = max(out[0],1)
res = 0
for i in range(len(out)):
    if out[i] != -1:
        res += out[i] * 10 ** (n-i-1)
print(res)
Buggy code:
N,M=map(int,input().split())
keta=[-1]*N
a=[]
for i in range(M):
    c1,c2=map(int,input().split())
    a.append([c1,c2])


for p in a:
    k=p[0]
    s=p[1]
    if keta[k-1] == -1:
        keta[k-1] = s
    elif keta[k-1] != s:
        print(-1)
        exit()

    
for i in range(10**(N-1),10**N):
    Q= str(i)
    flag=1
    for j in range(N):
        if keta[j]!= -1 and Q[j]==str(keta[j]):
            flag *= 1
        elif keta[j]!= -1 and Q[j] != str(keta[j]):
            flag *= 0

    if flag==1:
        print(i)
        break
else:
    print(0)

    


Fixed code:
N,M=map(int,input().split())
keta=[-1]*N
a=[]
for i in range(M):
    c1,c2=map(int,input().split())
    a.append([c1,c2])


for p in a:
    k=p[0]
    s=p[1]
    if keta[k-1] == -1:
        keta[k-1] = s
    elif keta[k-1] != s:
        print(-1)
        exit()


if N==1:
    for i in range(0,10**N):
        Q= str(i)
        flag=1
        for j in range(N):
            if keta[j]!= -1 and Q[j]==str(keta[j]):
                flag *= 1
            elif keta[j]!= -1 and Q[j] != str(keta[j]):
                flag *= 0

        if flag==1:
            print(i)
            exit()

    
    
for i in range(10**(N-1),10**N):
    Q= str(i)
    flag=1
    for j in range(N):
        if keta[j]!= -1 and Q[j]==str(keta[j]):
            flag *= 1
        elif keta[j]!= -1 and Q[j] != str(keta[j]):
            flag *= 0

    if flag==1:
        print(i)
        break
else:
    print(-1)
Buggy code:
N, M = map(int, input().split())
SC = []
for i in range(M):
    SC.append(list(map(int, input().split())))
flag = 0
N, M = 3, 1
SC = [[1, 0]]
a = ""
A = [[] for row in range(N)]
for i, S in enumerate(SC):
    if not (str(S[1]) in A[S[0]-1]):
        A[S[0]-1].append(str(S[1]))
for i in range(0,N):
    if len(A[i]) == 0:
        if i == 0:
            a += "1"
        else:
            a += "0"
    elif i==0 and A[i][0] == "0":
        flag = 1
        break
    elif len(A[i]) == 1:
        a += A[i][0]
    else:
        flag = 1
        break

if flag == 1:
    print(-1)
else:
    print(int(a))

Fixed code:
N, M = map(int, input().split())
SC = []
for i in range(M):
    SC.append(list(map(int, input().split())))
flag = 0
a = ""
A = [[] for row in range(N)]
for i, S in enumerate(SC):
    if not (str(S[1]) in A[S[0]-1]):
        A[S[0]-1].append(str(S[1]))
for i in range(0,N):
    if len(A[i]) == 0:
        if i == 0 and N>1:
            a += "1"
        else:
            a += "0"
    elif i==0 and A[i][0] == "0"  and N>1:
        flag = 1
        break
    elif len(A[i]) == 1:
        a += A[i][0]
    else:
        flag = 1
        break

if flag == 1:
    print(-1)
else:
    print(int(a))
Buggy code:
N, M = list(map(int, input().split()))

pattern = []
for _ in range(N):
    pattern.append(None)


nums = []
for _ in range(M):
    nums.append(list(map(int, input().split())))


cant_bool = False

for keta, num in nums:
    if pattern[keta - 1] == None:
        pattern[keta - 1] = num
    else:
        if pattern[keta - 1] == num:
            continue
        else:
            cant_bool = True

if cant_bool and not (len(nums) == 0):
    print(-1)
else:
    if pattern[0] == 0 and len(pattern) > 1:
        print(pattern)
        print(-1)
    else:
        pattern = [(0 if (num == None) else num) for num in pattern]
        if pattern[0] == 0 and len(pattern) > 1:
            pattern[0] = 1
        print(''.join(map(str, pattern)))


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

pattern = []
for _ in range(N):
    pattern.append(None)


nums = []
for _ in range(M):
    nums.append(list(map(int, input().split())))


cant_bool = False

for keta, num in nums:
    if pattern[keta - 1] == None:
        pattern[keta - 1] = num
    else:
        if pattern[keta - 1] == num:
            continue
        else:
            cant_bool = True

if cant_bool and not (len(nums) == 0):
    print(-1)
else:
    if pattern[0] == 0 and len(pattern) > 1:
        print(-1)
    else:
        pattern = [(0 if (num == None) else num) for num in pattern]
        if pattern[0] == 0 and len(pattern) > 1:
            pattern[0] = 1
        print(''.join(map(str, pattern)))
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())

ans = False
for x in range(10 ** (n - 1), 10 ** n):
    x = list(str(x))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        break

if n = 1:
    x = list(str(0))
        flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        break
    
if ans == False:
    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 = False

if n == 1:
    x = list(str(0))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        
for x in range(10 ** (n - 1), 10 ** n):
    x = list(str(x))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag and ans == False:
        print(int(''.join(x)))
        ans = True
        break


    
if ans == False:
    print(-1)
Buggy code:
import numpy as np
def getLine():
    return list(map(int, input().split()))
n,m = getLine()
r = np.full(n,-1)
for i in range(m):
    a,b = getLine()
    
    if r[a - 1] == -1:
        r[a - 1] = b
    elif r[a - 1] != b:
        print(-1)
        break
else:
    if (n > 1 and r[0] <= 0) or (n == 1 and r[0] < 0):
        print(-1)
    else:
        print(r)
        r[r == -1] = 0
        print(r)
        r = r.astype(str)
        print(int(''.join(r)))

Fixed code:
import numpy as np
def getLine():
    return list(map(int, input().split()))
n,m = getLine()
r = np.full(n,-1,dtype=int)
for i in range(m):
    a,b = getLine()
    
    if r[a - 1] == -1:
        r[a - 1] = b
    elif r[a - 1] != b:
        print(-1)
        break
else:
    if n > 1 and r[0] == 0:
        print(-1)
    else:
        if r[0] == 0 and n == 1:
            print('0')
        else:
            if n > 1 and r[0] == -1:
                r[0] = 1
            r[r == -1] = 0
            r = r.astype(str)
            print(''.join(r))
Buggy code:
from sys import exit

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

Query = []
for _ in range(M):
    Query.append(list(map(int,input().split())))

for i in range(10**(N-1),10**N):
    strnum = str(i)
    flag = True
    for j in Query:
        if strnum[j[0]-1] != str(j[1]):
            flag = False
            break
        else:
            None
    if flag:
        print(i)
        exit(0)
       
i = 0
strnum = str(i)
flag = True
for j in Query:
    if strnum[j[0]-1] != str(j[1]):
        flag = False
        break
    else:
        None
if flag:
    print(i)
    exit(0)
    
print('-1')

Fixed code:
from sys import exit

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

Query = []
for _ in range(M):
    Query.append(list(map(int,input().split())))

i = 0
if N == 1:
    flag0 = True
    for j in Query:
        if j[0] != 1 or j[1] != 0:
            flag0 = False
            break
        else:
            None
        
    if flag0:
        print(0)
        exit(0)

for i in range(10**(N-1),10**N):
    strnum = str(i)
    flag = True
    for j in Query:
        if strnum[j[0]-1] != str(j[1]):
            flag = False
            break
        else:
            None
    if flag:
        print(i)
        exit(0)
    
print('-1')
Buggy code:
N,M = map(int,input().split())
li =[]
for i in range(M):
    li.append(list(map(int,input().split())))
    if li[i][0]>N:
        print("-1")
        exit()
print(li)
for i in range(10**(N-1),10**N):
    inv = True
    a = str(i)
    for j in range(M):
        if  a[li[j][0]-1] != str(li[j][1]):
            inv = False
    if inv:
        print(i)
        exit()
print("-1")

Fixed code:
N,M = map(int,input().split())
li =[]
for i in range(M):
    li.append(list(map(int,input().split())))
    if li[i][0]>N:
        print("-1")
        exit()
st = 10**(N-1)
if N == 1:
    st = 0
for i in range(st,10**N):
    inv = True
    a = str(i)
    for j in range(M):
        if  a[li[j][0]-1] != str(li[j][1]):
            inv = False
            break
    if inv:
        print(i)
        exit()
print("-1")
Buggy code:
n, m = map(int, input().split())
lis = [list(map(int, input().split())) for _ in range(m)]
ans = -1
for i in range(1000):
    if len(str(i)) != n:
        continue
    else:
        s = 0
        for j in lis:
            if str(i)[j[0]-1] == str(j[1]):
                s += 1
    print(s)
    if s == m:
        ans = i
        break
print(ans)            

Fixed code:
n, m = map(int, input().split())
lis = [list(map(int, input().split())) for _ in range(m)]
ans = -1
for i in range(1000):
    if len(str(i)) != n:
        continue
    else:
        s = 0
        for j in lis:
            if str(i)[j[0]-1] == str(j[1]):
                s += 1

    if s == m:
        ans = i
        break
print(ans)