Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())

P = [list(map(int,input().split())) for i in range(M)]
s=[]
c=[]

for i in range(M):
    s.append(P[i][0])
    c.append(P[i][1])
A=[-1]*N

k=0
for i in range (M):
    if (A[s[i]-1]==-1) or (A[s[i]-1]==c[i]):
        A[s[i]-1]=c[i]
    else:
        k=1
        print(-1)
aa=0
if A[0]==0 and N>1:
    k=1
    print(-1)
if M==0:
    k=1
    print(pow(10,(N-1)))
if k==0:
    for i in range (M):
        if A[i]==-1:
            A[i] = 0
            if A[0]==0:
                A[0]=1

        aa+=A[i]*pow(10,(M-i-1))

    print(aa)


Fixed submission:
N,M = map(int, input().split())

P = [list(map(int,input().split())) for i in range(M)]
s=[]
c=[]

for i in range(M):
    s.append(P[i][0])
    c.append(P[i][1])
A=[-1]*N

k=0
for i in range (M):
    if (A[s[i]-1]==-1) or (A[s[i]-1]==c[i]):
        A[s[i]-1]=c[i]
    else:
        k=1
        print(-1)
aa=0
if A[0]==0 and N>1:
    k=1
    print(-1)
if M==0:
    k=1
    if N==1:
        print(0)
    else:
        print(pow(10,(N-1)))

if k==0:
    for i in range (N):
        if A[i]==-1:
            A[i] = 0
            if A[0]==0:
                A[0]=1

        aa+=A[i]*pow(10,(N-i-1))

    print(aa)

Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())

P = [list(map(int,input().split())) for i in range(M)]
s=[]
c=[]

for i in range(M):
    s.append(P[i][0])
    c.append(P[i][1])
A=[-1]*N

k=0
for i in range (M):
    if (A[s[i]-1]==-1) or (A[s[i]-1]==c[i]):
        A[s[i]-1]=c[i]
    else:
        k=1
        print(-1)
aa=0
if A[0]==0 and N>1:
    k=1
    print(-1)
if k==0:
    for i in range (M):
        if A[i]==-1:
            A[i] = 0
            if A[0]==0:
                A[0]=1

        aa+=A[i]*pow(10,(M-i-1))

    print(aa)

Fixed submission:
N,M = map(int, input().split())

P = [list(map(int,input().split())) for i in range(M)]
s=[]
c=[]

for i in range(M):
    s.append(P[i][0])
    c.append(P[i][1])
A=[-1]*N

k=0
for i in range (M):
    if (A[s[i]-1]==-1) or (A[s[i]-1]==c[i]):
        A[s[i]-1]=c[i]
    else:
        k=1
        print(-1)
aa=0
if A[0]==0 and N>1:
    k=1
    print(-1)
if M==0:
    k=1
    if N==1:
        print(0)
    else:
        print(pow(10,(N-1)))

if k==0:
    for i in range (N):
        if A[i]==-1:
            A[i] = 0
            if A[0]==0:
                A[0]=1

        aa+=A[i]*pow(10,(N-i-1))

    print(aa)

Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())

P = [list(map(int,input().split())) for i in range(M)]
s=[]
c=[]

for i in range(M):
    s.append(P[i][0])
    c.append(P[i][1])
A=[-1]*N

k=0
for i in range (M):
    if (A[s[i]-1]==-1) or (A[s[i]-1]==c[i]):
        A[s[i]-1]=c[i]
    else:
        k=1
        print(-1)
aa=0
if A[0]==0:
    k=1
    print(-1)
if k==0:
    for i in range (M):
        if A[i]==-1:
            A[i] = 0
            if A[0]==0:
                A[0]=1

        aa+=A[i]*pow(10,(M-i-1))

    print(aa)


Fixed submission:
N,M = map(int, input().split())

P = [list(map(int,input().split())) for i in range(M)]
s=[]
c=[]

for i in range(M):
    s.append(P[i][0])
    c.append(P[i][1])
A=[-1]*N

k=0
for i in range (M):
    if (A[s[i]-1]==-1) or (A[s[i]-1]==c[i]):
        A[s[i]-1]=c[i]
    else:
        k=1
        print(-1)
aa=0
if A[0]==0 and N>1:
    k=1
    print(-1)
if M==0:
    k=1
    if N==1:
        print(0)
    else:
        print(pow(10,(N-1)))

if k==0:
    for i in range (N):
        if A[i]==-1:
            A[i] = 0
            if A[0]==0:
                A[0]=1

        aa+=A[i]*pow(10,(N-i-1))

    print(aa)

Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())

P = [list(map(int,input().split())) for i in range(M)]
s=[]
c=[]

for i in range(M):
    s.append(P[i][0])
    c.append(P[i][1])
A=[-1]*N

k=0
for i in range (M):
    if (A[s[i]-1]==-1) or (A[s[i]-1]==c[i]):
        A[s[i]-1]=c[i]
    else:
        k=1
        print(-1)
aa=0
if A[0]==0:
    k=1
    print(-1)
if k==0:
    for i in range (M):
        if A[i]==-1:
            A[i] = 0
        aa+=A[i]*pow(10,(M-i-1))

    print(aa)

Fixed submission:
N,M = map(int, input().split())

P = [list(map(int,input().split())) for i in range(M)]
s=[]
c=[]

for i in range(M):
    s.append(P[i][0])
    c.append(P[i][1])
A=[-1]*N

k=0
for i in range (M):
    if (A[s[i]-1]==-1) or (A[s[i]-1]==c[i]):
        A[s[i]-1]=c[i]
    else:
        k=1
        print(-1)
aa=0
if A[0]==0 and N>1:
    k=1
    print(-1)
if M==0:
    k=1
    if N==1:
        print(0)
    else:
        print(pow(10,(N-1)))

if k==0:
    for i in range (N):
        if A[i]==-1:
            A[i] = 0
            if A[0]==0:
                A[0]=1

        aa+=A[i]*pow(10,(N-i-1))

    print(aa)

Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
#for _ in range(M):
#    s, c = map(int, input().split())
P = [list(map(int,input().split())) for i in range(M)]
s=[]
c=[]

for i in range(M):
    s.append(P[i][0])
    c.append(P[i][1])
A=[-1]*N

k=0
for i in range (M):
    if (A[s[i]-1]==-1) or (A[s[i]-1]==c[i]):
        A[s[i]-1]=c[i]
    else:
        k=1
        print(-1)
aa=0

if k==0:
    for i in range (M):
        if A[i]==-1:
            A[i] = 0
        aa+=A[i]*pow(10,(M-i-1))

    print(aa)

Fixed submission:
N,M = map(int, input().split())

P = [list(map(int,input().split())) for i in range(M)]
s=[]
c=[]

for i in range(M):
    s.append(P[i][0])
    c.append(P[i][1])
A=[-1]*N

k=0
for i in range (M):
    if (A[s[i]-1]==-1) or (A[s[i]-1]==c[i]):
        A[s[i]-1]=c[i]
    else:
        k=1
        print(-1)
aa=0
if A[0]==0 and N>1:
    k=1
    print(-1)
if M==0:
    k=1
    if N==1:
        print(0)
    else:
        print(pow(10,(N-1)))

if k==0:
    for i in range (N):
        if A[i]==-1:
            A[i] = 0
            if A[0]==0:
                A[0]=1

        aa+=A[i]*pow(10,(N-i-1))

    print(aa)