Buggy python submission (verdict: Runtime Error):
    N,M=map(int,input().split())
    sc=[list(map(int,input().split())) for _ in range(M)]
    for i in range(10**N):
        ans=str(i)
        if len(ans)==N and all(ans[s-1]==str(c) for s,c in sc):
            print(ans)
            quit()
    print(-1)

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

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
if n==1:
    c0=sc[0][1]
    for i in range(m):
        s=sc[i][0]
        c=sc[i][1]
        if c!=c0:
            print(-1)
            exit()
    print(c0)
    exit()
else:
    ans=10**5
    for i in range(10**(n-1),10**n):
        I=str(i)
        flag=True
        for j in range(m):
            s,c=sc[j][0],sc[j][1]
            if s==1 and c==0:
                print(-1)
                exit()
            if I[s-1]!=str(c):
                flag=False
                continue
        if flag:
            ans=i
    if ans==10**5:
        print(-1)
    else:
        print(ans)

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

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
if n==1:
    c0=sc[0][1]
    for i in range(m):
        s=sc[i][0]
        c=sc[i][1]
        if c!=c0:
            print(-1)
            exit()
    print(c0)
    exit()
else:
    ans=10**5
    for i in range(10**(n-1),10**n):
        I=str(i)
        flag=True
        for j in range(m):
            s,c=sc[j][0],sc[j][1]
            if s==1 and c==0:
                print(-1)
                exit()
            if I[s-1]!=str(c):
                flag=False
                continue
        if flag:
            ans=min(ans,i)
    if ans==10**5:
        print(-1)
    else:
        print(ans)

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

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
if n==1:
    c0=sc[0][1]
    for i in range(m):
        s=sc[i][0]
        c=sc[i][1]
        if c!=c0:
            print(-1)
            exit()
    print(c0)
    exit()
else:
    ans=10**5
    for i in range(10**(n-1),10**n):
        I=str(i)
        flag=True
        for j in range(m):
            s,c=sc[j][0],sc[j][1]
            if s==1 and c==0:
                print(-1)
                exit()
            if I[s-1]!=str(c):
                flag=False
                continue
        if flag:
            ans=min(ans,i)
    if ans==10**5:
        print(-1)
    else:
        print(ans)

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

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
if n==1:
    c0=sc[0][1]
    for i in range(m):
        s=sc[i][0]
        c=sc[i][1]
        if c!=c0:
            print(-1)
            exit()
    print(c0)
else:
    ans=10**5
    for i in range(10**(n-1),10**n):
        I=str(i)
        flag=True
        for j in range(m):
            s,c=sc[j][0],sc[j][1]
            if s==1 and c==0:
                print(-1)
                exit()
            if I[s-1]!=str(c):
                flag=False
                continue
        if flag:
            ans=min(ans,i)
    if ans==10**5:
        print(-1)
    else:
        print(ans)

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

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
if n==1:
    c0=sc[0][0]
    for i in range(m):
        s=sc[i][0]
        c=sc[i][1]
        if c!=c0:
            print(-1)
            exit()
    print(c0)
else:
    ans=10**5
    for i in range(10**(n-1),10**n):
        I=str(i)
        flag=True
        for j in range(m):
            s,c=sc[j][0],sc[j][1]
            if s==1 and c==0:
                print(-1)
                exit()
            if I[s-1]!=str(c):
                flag=False
                continue
        if flag:
            ans=min(ans,i)
    if ans==10**5:
        print(-1)
    else:
        print(ans)

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