Problem p02761 (python)

Fixed submission:
import sys
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

n,m  = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
d = {}
if m == 0 and n != 1:
    print(10**(n-1))
    sys.exit()
if m == 0 and n == 1:
    print("0")
    sys.exit()
    
for i in l:
    if i[0] in d and  i[1] !=d[i[0]]:
        d[i[0]] += 1
        print("-1")
        sys.exit()
    else:
        d[i[0]] =i[1]
#ここまでが同一桁に複数の数字が指定されていた時の処理

l = get_unique_list(l) #重複削除
l.sort() #ソート
d = 0
if l[0][1]==0 and l[0][0]==1: #1桁目が0
    if n ==1: #1桁指定の時
        print("0")
        sys.exit()
    else:
        print("-1")
        sys.exit()
        
if l[0][0]!=1: #1桁目に指定がない
    d = 10**(n-1)
    for i in l:
        d += i[1]*10**(n-i[0])
        
else:
    for i in l:
        d += i[1]*10**(n-i[0])    

print(d)

Buggy submission (verdict: Runtime Error):
import sys
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

n,m  = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
d = {}
if m == 0 and n != 0:
    print(10**(n-1))
    sys.exit()
if m = =0 and n == 0:
    print("0")
    
for i in l:
    if i[0] in d and  i[1] !=d[i[0]]:
        d[i[0]] += 1
        print("-1")
        sys.exit()
    else:
        d[i[0]] =i[1]
#ここまでが同一桁に複数の数字が指定されていた時の処理

l = get_unique_list(l) #重複削除
l.sort() #ソート
d = 0
if l[0][1]==0 and l[0][0]==1: #1桁目が0
    if n ==1: #1桁指定の時
        print("0")
        sys.exit()
    else:
        print("-1")
        sys.exit()
        
if l[0][0]!=1: #1桁目に指定がない
    d = 10**(n-1)
    for i in l:
        d += i[1]*10**(n-i[0])
        
else:
    for i in l:
        d += i[1]*10**(n-i[0])    

print(d)

Buggy submission (verdict: Runtime Error):
import sys
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

n,m  = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
d = {}
for i in l:
    if i[0] in d and d[i[0]] != i[1]:
        d[i[0]] += 1
        print("-1")
        sys.exit()
    else:
        d[i[0]] =i[1]

#ここまでが同一桁に複数の数字が指定されていた時の処理

l = get_unique_list(l) #重複削除
l.sort() #ソート
d = 0
if l[0][1]==0 and l[0][0]==1: #1桁目が0
    if n ==1: #1桁指定の時
        print("0")
        sys.exit()
    else:
        print("-1")
        sys.exit()
        
if l[0][0]!=1: #1桁目に指定がない
    d = 10**(n-1)
    for i in l:
        d += int(i[1])*10**(n-int(i[0]))
        
else:
    for i in l:
        d += i[1]*10**(n-i[0])    

print(d)

Buggy submission (verdict: Runtime Error):
import sys
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

n,m  = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
d = {}
for i in l:
    if i[0] in d and d[i[0]] != i[0]:
        d[i[0]] += 1
        print("-1")
        sys.exit()
    else:
        d[i[0]] =i[1]

#ここまでが同一桁に複数の数字が指定されていた時の処理

l = get_unique_list(l) #重複削除
l.sort() #ソート
d = 0
if l[0][1]==0 and l[0][0]==1: #1桁目が0
    if n ==1: #1桁指定の時
        print("0")
        sys.exit()
    else:
        print("-1")
        sys.exit()
        
if l[0][0]!=1: #1桁目に指定がない
    d = 10**(n-1)
    for i in l:
        d += int(i[1])*10**(n-int(i[0]))
        
else:
    for i in l:
        d += i[1]*10**(n-i[0])    

print(d)

Buggy submission (verdict: Runtime Error):
import sys
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]


n,m  = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
length = len(l)
d = {}
for i in l:
    if i[0] in d and d[i[0]] != i[0]:
        d[i[0]] += 1
        break
    else:
        d[i[0]] =1
for j in d.values():
    if j != 1:
        print("-1")
        sys.exit()

l = get_unique_list(l)
l.sort()
d = 0
if l[0][1]==0 and l[0][0]==1:
    if n ==1:
        print("0")
        sys.exit()
    else:
        print("-1")
        sys.exit()
if l[0][0]!=1:
    d = 10**(n-1)
    for i in l:
        d += int(i[1])*10**(n-int(i[0]))
        
else:
    for i in l:
        d += int(i[1])*10**(n-int(i[0]))
print(d)

Buggy submission (verdict: Runtime Error):
import sys
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]


n,m  = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
length = len(l)
d = {}
for i in l:
    if i[0] in d and d[i[0]] != i[0]:
        d[i[0]] += 1
        break
    else:
        d[i[0]] =1
for j in d.values():
    if j != 1:
        print("-1")
        sys.exit()

l = get_unique_list(l)
l.sort()
d = 0
if l[0][1]==0 and l[0][0]==1:
    if n ==1:
        print("0")
        sys.exit()
    else:
        print("-1")
        sys.exit()
else:
    for i in l:
        d += int(i[1])*10**(n-int(i[0]))
print(d)