Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for _ in range(m):
    s,c=map(int,input().split())
    a.append([s,c])

ans='-1'
for i in range(10**n):
    x=str(i)
    c=0
    for j in range(m):
        if x[a[j][0]-1] == str(a[j][1]):
            c+=1
    if c==m:
        ans=i
        break
print(ans)

Fixed submission:
n,m=map(int,input().split())
a=[]
for _ in range(m):
    s,c=map(int,input().split())
    a.append([s,c])

ans=-1
if n==1:
    for i in range(10):
        x=str(i)
        c=0
        for j in range(m):
            if x[a[j][0]-1] == str(a[j][1]):
                c+=1          
        if c==m:
            ans=i
            break
else:
    for i in range(10**(n-1),10**n):
        x=str(i)
        c=0
        for j in range(m):
            if x[a[j][0]-1] == str(a[j][1]):
                c+=1          
        if c==m:
            ans=i
            break
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=[]
for _ in range(n):
    x.append([])

for _ in range(m):
    s,c=map(int,input().split())
    x[s-1].append(c)
ans=''
for i in range(n):
    if len(set(x[i]))>=2:
        ans='-1'
        break
    elif len(x[i])==0 and i==0:
        ans+='1'
    elif len(x[i])==0 and i!=0:
        ans+='0'
    else:
        if x[0][0]==0 and n==1:
            ans='0'
            break
        elif x[0][0]==0 and n!=1:
            ans='-1'
            break
        ans+=str(x[i][0])

print(int(ans))


Fixed submission:
n,m=map(int,input().split())
a=[]
for _ in range(m):
    s,c=map(int,input().split())
    a.append([s,c])

ans=-1
if n==1:
    for i in range(10):
        x=str(i)
        c=0
        for j in range(m):
            if x[a[j][0]-1] == str(a[j][1]):
                c+=1          
        if c==m:
            ans=i
            break
else:
    for i in range(10**(n-1),10**n):
        x=str(i)
        c=0
        for j in range(m):
            if x[a[j][0]-1] == str(a[j][1]):
                c+=1          
        if c==m:
            ans=i
            break
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=[]
for _ in range(n):
    x.append([])

for _ in range(m):
    s,c=map(int,input().split())
    x[s-1].append(c)
ans=''
for i in range(n):
    if len(set(x[i]))>=2:
        ans='-1'
        break
    elif len(x[i])==0 and i==0:
        ans+='1'
    elif len(x[i])==0 and i!=0:
        ans+='0'
    else:
        if x[0][0]==0 and n==1:
            ans='0'
            break
        elif x[0][0]==0 and n!=1:
            ans='-1'
            break
        ans+=str(x[i][0])

print(int(ans))


Fixed submission:
n,m=map(int,input().split())
a=[]
for _ in range(m):
    s,c=map(int,input().split())
    a.append([s,c])

ans=-1
if n==1:
    for i in range(10):
        x=str(i)
        c=0
        for j in range(m):
            if x[a[j][0]-1] == str(a[j][1]):
                c+=1          
        if c==m:
            ans=i
            break
else:
    for i in range(10**(n-1),10**n):
        x=str(i)
        c=0
        for j in range(m):
            if x[a[j][0]-1] == str(a[j][1]):
                c+=1          
        if c==m:
            ans=i
            break
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=[]
for _ in range(n):
    x.append([])

for _ in range(m):
    s,c=map(int,input().split())
    x[s-1].append(c)
ans=''
for i in range(n):
    if len(set(x[i]))>=2:
        ans='-1'
        break
    if len(x[i])==0 and i==0:
        ans='1'
    if len(x[i])==0 and i!=0:
        ans='0'
    ans+=str(x[i][0])
print(int(ans))

Fixed submission:
n,m=map(int,input().split())
a=[]
for _ in range(m):
    s,c=map(int,input().split())
    a.append([s,c])

ans=-1
if n==1:
    for i in range(10):
        x=str(i)
        c=0
        for j in range(m):
            if x[a[j][0]-1] == str(a[j][1]):
                c+=1          
        if c==m:
            ans=i
            break
else:
    for i in range(10**(n-1),10**n):
        x=str(i)
        c=0
        for j in range(m):
            if x[a[j][0]-1] == str(a[j][1]):
                c+=1          
        if c==m:
            ans=i
            break
print(ans)