Problem p02761 (python)

Fixed submission:
n,m = map(int,input().split())
L = []
for i in range(m):
    L.append(list((map(int,input().split()))))

for i in range(1000):
    p = str(i)
    flag = False
    for j in range(m):
        if len(p) >= L[j][0]:
            if int(p[L[j][0]-1]) != L[j][1]:
                break
    else:
        if len(p) == n:
            flag = True

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

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
L = [-1]*n
lia,lib = [],[]
flag = True

for i in range(m):
    a,b = map(int,input().split())
    lia.append(a-1)
    lib.append(b)

for i in range(len(lia)):
    if L[i] == -1:
        L[lia[i]] = lib[i]

if n == 1:
    if L[0] != -1:
        print(L[0])
        exit()
else:
    if L[0] == 0:
        print(-1)
        exit()
    elif L[0] == -1:
        L[0] = 1
    
for i in range(n):
    if L[i] == -1:
        L[i] = 0
L = [str(x) for x in L]
print("".join(L))

Buggy submission (verdict: Runtime Error):
 = [-1]*n
li = []
flag = True

for i in range(m):
    a,b = map(int,input().split())
    if n == 1:
        if a == 1:
            L[0] = b
            break
        else:
            flag = False
    else:
        if (a in li) and L[a-1] != b:
            flag = False
            break
        elif a == 1 and b == 0:
            flag = False
            break
        else:
            L[a-1] = b
            li.append(a)
for i in range(n):
    if L[i] == -1:
        L[i] = 0
if flag:
    L = [str(x) for x in L]
    print("".join(L))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
L = []

for i in range(m):
    L.append(list(((map(int,input().split())))))
#print(L)
if len(L) == 0:
    print(-1)
    exit()
li = [-1]*n
dic = {}
for i in range(m):
    if L[i][0] not in dic:
        dic[L[i][0]] = L[i][1]
#print(dic)
for i in range(m):
    if dic[L[i][0]] != L[i][1]:
        print(-1)
        exit()
    try:
        li[L[i][0]-1] = L[i][1]
    except IndexError:
        print(-1)
        exit()
#print(li)
if n == 1:
    print(li[0])
    exit()
else:
    for i in range(m):
        if li[i] == -1:
            li[i] = 0
    if li[0] == 0:
        print(-1)
        exit()
    else:
        li = [str(x) for x in li]
print("".join(li))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
L = []

for i in range(m):
    L.append(list(((map(int,input().split())))))
#print(L)
if len(L) == 0:
    print(-1)
    exit()
li = [-1]*n
dic = {}
for i in range(m):
    if L[i][0] not in dic:
        dic[L[i][0]] = L[i][1]
#print(dic)
for i in range(m):
    if dic[L[i][0]] != L[i][1]:
        print(-1)
        exit()
    li[L[i][0]-1] = L[i][1]
#print(li)
if n == 1:
    print(li[0])
    exit()
else:
    for i in range(m):
        if li[i] == -1:
            li[i] = 0
    if li[0] == 0:
        print(-1)
        exit()
    else:
        li = [str(x) for x in li]
print("".join(li))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
L = []
for i in range(m):
    L.append(list(((map(int,input().split())))))
#print(L)
if L == False:
    print(-1)
    exit()
li = [-1]*n
dic = {}
for i in range(m):
    if L[i][0] not in dic:
        dic[L[i][0]] = L[i][1]
#print(dic)
for i in range(m):
    if dic[L[i][0]] != L[i][1]:
        print(-1)
        exit()
    li[L[i][0]-1] = L[i][1]
#print(li)
if n == 1:
    print(li[0])
    exit()
else:
    for i in range(m):
        if li[i] == -1:
            li[i] = 0
    if li[0] == 0:
        print(-1)
        exit()
    else:
        li = [str(x) for x in li]
print("".join(li))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
#L= list(map(int, input().split()))
L = []
for i in range(m):
    a = list(map(int, input().split()))
    L.append(a)
#print(L)
if n == 1:
    print(0)
    exit()
if m == 0:
    print(-1)
    exit()
s = [-1]*n
for i in range(m):
    s[L[i][0]-1] = L[i][1]
#print(L,s)

for i in range(1,m):
    if s[i]==-1:
        s[i] = 0
    #print(s)
if s[0] == 0:
    print(0)
    exit()

ans = ""
for i in range(m):
    ans += str(s[i])
print(int(ans))

Buggy submission (verdict: Runtime Error):
#n = int(input())
n,m = map(int,input().split())
#L= list(map(int, input().split()))
L = []
for i in range(m):
    a = list(map(int, input().split()))
    L.append(a)

if n == 1:
    print(0)
    exit()
if m == 0:
    print(-1)
s = [-1]*n
for i in range(m):
    s[L[i][0]-1] = L[i][1]
print(L,s)
if s[0] == 0:
    print(-1)
    exit()

for i in range(1,m):
    if s[i]==-1:
        s[i] = 0
    print(s)
ans = ""
for i in range(m):
    ans += str(s[i])
print(int(ans))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
#L= list(map(int, input().split()))
L = []
for i in range(m):
    a = list(map(int, input().split()))
    L.append(a)

if n == 1:
    print(0)
    exit()
    
s = [-1]*n
for i in range(m):
    s[L[i][0]-1] = L[i][1]
#print(L,s)
for i in range(m):
    if s[0] == 0:
        print(-1)
        exit()
    if s[i]==-1:
        s[i] = 0
    #print(s)
ans = ""
for i in range(m):
    ans += str(s[i])
print(int(ans))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
#L= list(map(int, input().split()))
L = []
for i in range(m):
    a = list(map(int, input().split()))
    L.append(a)

s = [-1]*n
for i in range(m):
    s[L[i][0]-1] = L[i][1]

for i in range(m):
    if s[0] == 0:
        print(-1)
        exit()
    if s[i]==-1:
        s[i] = 0
ans = ""
for i in range(m):
    ans += str(s[i])
print(ans)