Problem p02761 (python)

Fixed submission:
# n,m = map(int, input().split())
# sc = [map(int, input().split()) for _ in range(m)]
# s, c = [list(i) for i in zip(*sc)]
#
#
#
# for i in range(10**n):
#     ans = str(i)
#     if len(i) == n and all([i[s[j]-1] == str(c[j]) for j in range(m)]):
#         print(ans)
#         exit()
#
#
# print(-1)

n, m = map(int, input().split())

s, c = [], []
for _ in range(m):
    s_, c_ = map(int, input().split())
    s.append(s_)
    c.append(c_)

for i in range(10 ** n):
    ans = str(i)
    if len(ans) == n and all([ans[s[j] - 1] == str(c[j]) for j in range(m)]):
        print(ans)
        exit()

print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc = [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]



for i in range(10**n):
    ans = str(i)
    if len(i) == n and all([i[s[j]-1] == str(c[j]) for j in range(m)]):
        print(ans)
        exit()


print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]



for i in range(10**n):
    ans = str(i)
    if len(i) == n and all([i[s[j]-1] == str(c[j]) for j in range(m)]):
        print(ans)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]



for ans in range(10**n):
    ans = str(ans)
    if len(ans) == n and all([ans[s[j]-1] == str(c[j]) for j in range(m)]):
        print(ans)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]



for ans in range(10**n):
    ans = str(ans)
    if len(ans) == n and all(ans[s[j]-1] == str(c[j]) for j in range(m)):
        print(ans)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]

ans = 10001


for l in range((10**(n-1)),10**n):
    ln = str(l)
    tmp = 0
    tmp0 = 0
    for j in range(m):
        if s[j] == 0:
            tmp0 += 1
            if tmp0 == m:
                ans = 0
                break

        elif int(ln[int(s[j])-1]) == int(c[j]):
            tmp += 1
            # print(tmp)
            if tmp == m:
                ans = int(ln)
        else:
            # print(tmp)
            break
    if ans != 10001:
        break



if ans == 0:
    print(0)

elif ans == 10001:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]

ans = 10001


for l in range((10**(n-1)),10**n):
    ln = str(l)
    tmp = 0
    for j in range(m):
        if int(ln[int(s[j])-1]) == int(c[j]):
            tmp += 1
            # print(tmp)
            if tmp == m:
                ans = int(ln)

                break

        else:
            # print(tmp)
            break
    if ans != 10001:
        break
for i in range(m):
    tmp = 0
    if s[i] == 0:
        tmp += 1
        if tmp == m:
            ans = 0


if ans == 0:
    print(0)

elif ans == 10001:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]

ans = 10001
for i in range(m):
    tmp = 0
    if s[i] == 0:
        tmp += 1
    elif tmp == m:
        print(0)

for l in range((10**(n-1)),10**n):
    ln = str(l)


    tmp = 0
    for j in range(m):
        if int(ln[int(s[j])-1]) == int(c[j]):
            tmp += 1
            # print(tmp)
            if tmp == m:
                ans = int(ln)
                print(ans)
                break

        else:
            # print(tmp)
            break
    if ans != 10001:
        break

if ans == 10001:
    print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]

ans = 10001
for i in range(m):
    if s[i]==0:
        print(0)
for l in range((10**(n-1)),10**n):
    ln = str(l)


    tmp = 0
    for j in range(m):
        if int(ln[int(s[j])-1]) == int(c[j]):
            tmp += 1
            # print(tmp)
            if tmp == m:
                ans = int(ln)
                print(ans)
                break

        else:
            # print(tmp)
            break
    if ans != 10001:
        break

if ans == 10001:
    print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]

ans = 10001
for l in range((10**(n-1))+1,10**n):
    ln = str(l)


    tmp = 0
    for j in range(m):
        if int(ln[int(s[j])-1]) == int(c[j]):
            tmp += 1
            # print(tmp)
            if tmp == m:
                ans = int(ln)
                print(ans)
                break

        else:
            # print(tmp)
            break
    if ans != 10001:
        break

if ans == 10001:
    print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]

ans = 10001
for l in range((10**(n-1))+1,10**n):
    ln = str(l)
    #ln = l

    tmp = 0
    for j in range(m):
        if int(ln[int(s[j])-1]) == int(c[j]):
            tmp += 1
            # print(tmp)
            if tmp == m:
                ans = int(ln)
                print(ans)
                break

        else:
            # print(tmp)
            break
    if ans != 10001:
        break

if ans == 10001:
    print(-1)