Buggy python submission (verdict: Runtime Error):
import sys

n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]

sc.sort(key=lambda x:x[0])
sc.sort()
anl =[0 for i in range(n)]
an = 0

if sc[0][1]==0:
    if n>1:
        print('-1')
        sys.exit()
    else:
        print(0)
        sys.exit()

for i in range(m):
    for j in range(1,m):
        if sc[i][0] == sc[j][0] and sc[i][1]!=sc[j][1]:
            print('-1')
            sys.exit()
        else:
            anl[sc[i][0]-1] = sc[i][1]

if anl[n-1]==0:
    print('-1')
    sys.exit()

for i in range(n):
    an += 10**(n-i-1)*anl[i]
print(an)

Fixed submission:
import sys

def ans(anl,n):
    an = 0
    for i in range(n):
        an += 10**(n-i-1)*anl[i]
    return(an)

n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]

sc.sort(key=lambda x:x[0])
sc.sort()
anl =[0 for i in range(n)]
anl[0] = 1

if m == 0:
    if n == 1:
        print(0)
        sys.exit()
    else:
        print(10**(n-1))
        sys.exit()
if m == 1:
    if sc[0][1] == 0 and n == 1:
        print(0)
        sys.exit()
    anl[sc[0][0]-1] = sc[0][1]
    if anl[0] == 0:
        print('-1')
        sys.exit()
    print(ans(anl,n))
    sys.exit()

for i in range(m):
    for j in range(1,m):
        if sc[i][0] == sc[j][0] and sc[i][1]!=sc[j][1]:
            print('-1')
            sys.exit()
        else:
            anl[sc[i][0]-1] = sc[i][1]

if anl[0] == 0:
    print('-1')
    sys.exit()

print(ans(anl,n))

Buggy python submission (verdict: Runtime Error):
import sys

n,m = map(int,input().split())
a = []
wk =[]
kai = 0
for i in range(m):
    wk = (list(map(int,input().split())))
    if wk in a:
        m -= 1
    else:
        a.append(wk)

a.sort()

if a[0][1] == 0:
        print('-1')
        sys.exit()
for i in range(m):
    if a[i][1]==n and a[i][1]==0:
        print('-1')
        sys.exit()
for i in range(m-1):
    if a[i][0] == a[i+1][0]:
        print('-1')
        sys.exit()

for i in range(m):
    kai += (10**(n-a[i][0]))*a[i][1]

print(kai)

Fixed submission:
import sys

def ans(anl,n):
    an = 0
    for i in range(n):
        an += 10**(n-i-1)*anl[i]
    return(an)

n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]

sc.sort(key=lambda x:x[0])
sc.sort()
anl =[0 for i in range(n)]
anl[0] = 1

if m == 0:
    if n == 1:
        print(0)
        sys.exit()
    else:
        print(10**(n-1))
        sys.exit()
if m == 1:
    if sc[0][1] == 0 and n == 1:
        print(0)
        sys.exit()
    anl[sc[0][0]-1] = sc[0][1]
    if anl[0] == 0:
        print('-1')
        sys.exit()
    print(ans(anl,n))
    sys.exit()

for i in range(m):
    for j in range(1,m):
        if sc[i][0] == sc[j][0] and sc[i][1]!=sc[j][1]:
            print('-1')
            sys.exit()
        else:
            anl[sc[i][0]-1] = sc[i][1]

if anl[0] == 0:
    print('-1')
    sys.exit()

print(ans(anl,n))

Buggy python submission (verdict: Runtime Error):
import sys

n,m = map(int,input().split())
a = []
wk =[]
kai = 0
for i in range(m):
    wk = (list(map(int,input().split())))
    if wk in a:
        m -= 1
    else:
        a.append(wk)

a.sort()

if a[0][1] == 0:
        print('-1')
        sys.exit()
for i in range(m):
    if a[i][1]==n and a[i][1]==0:
        print('-1')
        sys.exit()
for i in range(m-1):
    if a[i][0] == a[i+1][0]:
        print('-1')
        sys.exit()

for i in range(m):
    kai += (10**(n-a[i][0]))*a[i][1]

print(kai)

Fixed submission:
import sys

def ans(anl,n):
    an = 0
    for i in range(n):
        an += 10**(n-i-1)*anl[i]
    return(an)

n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]

sc.sort(key=lambda x:x[0])
sc.sort()
anl =[0 for i in range(n)]
anl[0] = 1

if m == 0:
    if n == 1:
        print(0)
        sys.exit()
    else:
        print(10**(n-1))
        sys.exit()
if m == 1:
    if sc[0][1] == 0 and n == 1:
        print(0)
        sys.exit()
    anl[sc[0][0]-1] = sc[0][1]
    if anl[0] == 0:
        print('-1')
        sys.exit()
    print(ans(anl,n))
    sys.exit()

for i in range(m):
    for j in range(1,m):
        if sc[i][0] == sc[j][0] and sc[i][1]!=sc[j][1]:
            print('-1')
            sys.exit()
        else:
            anl[sc[i][0]-1] = sc[i][1]

if anl[0] == 0:
    print('-1')
    sys.exit()

print(ans(anl,n))