Buggy python submission (verdict: Runtime Error):
import sys

N,M = map(int,input().split())
SC=[]

ans=0

for i in range(M):
    S,C = map(int,input().split())
    SC.append((S,C))

if N==1:
    if SC[0][1]==0:
        print(0)
        sys.exit()

for i in range(M):
    for j in range(M):
        if SC[i][0]==SC[j][0]:
            if not SC[i][1]==SC[j][1]:
                print(-1)
                sys.exit()
    if not N==1:
            if SC[i][0]==1:
                if SC[i][1]==0:
                    print(-1)
                    sys.exit()


            
SC=tuple(set(SC))
l=len(SC)

for i in range(l):
    a=SC[i][0]
    b=SC[i][1]
    ans=ans+(10**(N-a))*b

print(ans)

Fixed submission:
import sys

N,M = map(int,input().split())
SC=[]

ans=0

for i in range(M):
    S,C = map(int,input().split())
    SC.append((S,C))

for i in range(M):
    for j in range(M):
        if SC[i][0]==SC[j][0]:
            if not SC[i][1]==SC[j][1]:
                print(-1)
                sys.exit()
    if not N==1:
            if SC[i][0]==1:
                if SC[i][1]==0:
                    print(-1)
                    sys.exit()

if M==0:
    if N==1:
        print(0)
        sys.exit()
    else:
        print(10**(N-1))
        sys.exit()

            
SC=tuple(set(SC))
l=len(SC)

for i in range(l):
    a=SC[i][0]
    b=SC[i][1]
    ans=ans+(10**(N-a))*b
if not N==1:
    if ans<10**(N-1):
        ans=ans+10**(N-1)

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys

N,M = map(int,input().split())
SC=[]

ans=0

for i in range(M):
    S,C = map(int,input().split())
    SC.append((S,C))

if N==1:
    if SC[0][1]==0:
        print(0)
        sys.exit()

for i in range(M):
    for j in range(M):
        if SC[i][0]==SC[j][0]:
            if not SC[i][1]==SC[j][1]:
                print(-1)
                sys.exit()
SC=tuple(set(SC))
l=len(SC)

for i in range(l):
    a=SC[i][0]
    b=SC[i][1]
    ans=ans+(10**(N-a))*b

print(ans)

Fixed submission:
import sys

N,M = map(int,input().split())
SC=[]

ans=0

for i in range(M):
    S,C = map(int,input().split())
    SC.append((S,C))

for i in range(M):
    for j in range(M):
        if SC[i][0]==SC[j][0]:
            if not SC[i][1]==SC[j][1]:
                print(-1)
                sys.exit()
    if not N==1:
            if SC[i][0]==1:
                if SC[i][1]==0:
                    print(-1)
                    sys.exit()

if M==0:
    if N==1:
        print(0)
        sys.exit()
    else:
        print(10**(N-1))
        sys.exit()

            
SC=tuple(set(SC))
l=len(SC)

for i in range(l):
    a=SC[i][0]
    b=SC[i][1]
    ans=ans+(10**(N-a))*b
if not N==1:
    if ans<10**(N-1):
        ans=ans+10**(N-1)

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys

N,M = map(int,input().split())
SC=[]

ans=0

for i in range(M):
    S,C = map(int,input().split())
    SC.append((S,C))

if N==1:
    if SC[0][1]==0:
        print(0)
        sys.exit()

for i in range(M):
    for j in range(M):
        if SC[i][0]==SC[j][0]:
            if not SC[i][1]==SC[j][1]:
                print(-1)
                sys.exit()
    if SC[i][0]==1:
        if SC[i][1]==0:
            print(-1)
            sys.exit()
            
SC=tuple(set(SC))
l=len(SC)

for i in range(l):
    a=SC[i][0]
    b=SC[i][1]
    ans=ans+(10**(N-a))*b

print(ans)

Fixed submission:
import sys

N,M = map(int,input().split())
SC=[]

ans=0

for i in range(M):
    S,C = map(int,input().split())
    SC.append((S,C))

for i in range(M):
    for j in range(M):
        if SC[i][0]==SC[j][0]:
            if not SC[i][1]==SC[j][1]:
                print(-1)
                sys.exit()
    if not N==1:
            if SC[i][0]==1:
                if SC[i][1]==0:
                    print(-1)
                    sys.exit()

if M==0:
    if N==1:
        print(0)
        sys.exit()
    else:
        print(10**(N-1))
        sys.exit()

            
SC=tuple(set(SC))
l=len(SC)

for i in range(l):
    a=SC[i][0]
    b=SC[i][1]
    ans=ans+(10**(N-a))*b
if not N==1:
    if ans<10**(N-1):
        ans=ans+10**(N-1)

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys

N,M = map(int,input().split())
SC=[]

ans=0

for i in range(M):
    S,C = map(int,input().split())
    SC.append((S,C))

if N==1:
    if SC[0][1]==0:
        print(0)
        sys.exit()

for i in range(M):
    for j in range(M):
        if SC[i][0]==SC[j][0]:
            if not SC[i][1]==SC[j][1]:
                print(-1)
                sys.exit()
    if SC[i][0]==1:
        if SC[i][1]==0:
            print(-1)
            sys.exit()
            
SC=tuple(set(SC))
l=len(SC)

for i in range(l):
    a=SC[i][0]
    b=SC[i][1]
    ans=ans+(10**(N-a))*b

print(ans)

Fixed submission:
import sys

N,M = map(int,input().split())
SC=[]

ans=0

for i in range(M):
    S,C = map(int,input().split())
    SC.append((S,C))

for i in range(M):
    for j in range(M):
        if SC[i][0]==SC[j][0]:
            if not SC[i][1]==SC[j][1]:
                print(-1)
                sys.exit()
    if not N==1:
            if SC[i][0]==1:
                if SC[i][1]==0:
                    print(-1)
                    sys.exit()

if M==0:
    if N==1:
        print(0)
        sys.exit()
    else:
        print(10**(N-1))
        sys.exit()

            
SC=tuple(set(SC))
l=len(SC)

for i in range(l):
    a=SC[i][0]
    b=SC[i][1]
    ans=ans+(10**(N-a))*b
if not N==1:
    if ans<10**(N-1):
        ans=ans+10**(N-1)

print(ans)