Buggy python submission (verdict: Runtime Error):
s = []
ans = 0
flag = True
N, M = map(int, input().split())
for i in range(M):
    a = list(map(int, input().split()))
    if a not in s:
        s.append(a)
S = sorted(s)

for i in range(len(S)-1):
    if S[i][0]==S[i+1][0] and S[i][1]!=S[i+1][1]:
        flag = False

if N>1 and S[0]==[1,0]:
    flag = False

if flag == True:
    for i in range(len(S)):
        for j in range(N+1):
            if S[i][0]==j:
                ans+=S[i][1]*10**(N-j)
    if N==3 and ans<100:
        ans+=100
    elif N ==2 and ans<10:
        ans+=10
        
    print(ans)
            
else:
    print('-1')

Fixed submission:
s = []
ans = 0
flag = True
N, M = map(int, input().split())
if M ==0:
    if N==1:
        print(0)
    elif N ==2:
        print(10)
    else:
        print(100)
else:
    for i in range(M):
        a = list(map(int, input().split()))
        if a not in s:
            s.append(a)
    S = sorted(s)

    for i in range(len(S)-1):
        if S[i][0]==S[i+1][0] and S[i][1]!=S[i+1][1]:
            flag = False

    if N>1 and S[0]==[1,0]:
        flag = False

    if flag == True:
        for i in range(len(S)):
            for j in range(N+1):
                if S[i][0]==j:
                    ans+=S[i][1]*10**(N-j)
        if N==3 and ans<100:
            ans+=100
        elif N ==2 and ans<10:
            ans+=10
        
        print(ans)
            
    else:
        print('-1')

Buggy python submission (verdict: Runtime Error):
s = []
ans = 0
flag = True
N, M = map(int, input().split())
for i in range(M):
    a = list(map(int, input().split()))
    if a not in s:
        s.append(a)
S = sorted(s)

for i in range(len(S)-1):
    if S[i][0]==S[i+1][0] and S[i][1]!=S[i+1][1]:
        flag = False

if N>1 and S[0]==[1,0]:
    flag = False

if flag == True:
    for i in range(len(S)):
        for j in range(N+1):
            if S[i][0]==j:
                ans+=S[i][1]*10**(N-j)
    if N==3 and ans<100:
        ans+=100
    elif N ==2 and ans<10:
        ans+=10
        
    print(ans)
            
else:
    print('-1')

Fixed submission:
s = []
ans = 0
flag = True
N, M = map(int, input().split())
if M ==0:
    if N==1:
        print(0)
    elif N ==2:
        print(10)
    else:
        print(100)
else:
    for i in range(M):
        a = list(map(int, input().split()))
        if a not in s:
            s.append(a)
    S = sorted(s)

    for i in range(len(S)-1):
        if S[i][0]==S[i+1][0] and S[i][1]!=S[i+1][1]:
            flag = False

    if N>1 and S[0]==[1,0]:
        flag = False

    if flag == True:
        for i in range(len(S)):
            for j in range(N+1):
                if S[i][0]==j:
                    ans+=S[i][1]*10**(N-j)
        if N==3 and ans<100:
            ans+=100
        elif N ==2 and ans<10:
            ans+=10
        
        print(ans)
            
    else:
        print('-1')

Buggy python submission (verdict: Runtime Error):
s = []
ans = 0
flag = True
N, M = map(int, input().split())
for i in range(M):
    a = list(map(int, input().split()))
    if a not in s:
        s.append(a)
S = sorted(s)

for i in range(len(S)-1):
    if S[i][0]==S[i+1][0] and S[i][1]!=S[i+1][1]:
        flag = False

if N>1 and S[0]==[1,0]:
    flag = False

if flag == True:
    for i in range(len(S)):
        for j in range(N+1):
            if S[i][0]==j:
                ans+=S[i][1]*10**(N-j)
    print(ans)
            
else:
    print(-1)

Fixed submission:
s = []
ans = 0
flag = True
N, M = map(int, input().split())
if M ==0:
    if N==1:
        print(0)
    elif N ==2:
        print(10)
    else:
        print(100)
else:
    for i in range(M):
        a = list(map(int, input().split()))
        if a not in s:
            s.append(a)
    S = sorted(s)

    for i in range(len(S)-1):
        if S[i][0]==S[i+1][0] and S[i][1]!=S[i+1][1]:
            flag = False

    if N>1 and S[0]==[1,0]:
        flag = False

    if flag == True:
        for i in range(len(S)):
            for j in range(N+1):
                if S[i][0]==j:
                    ans+=S[i][1]*10**(N-j)
        if N==3 and ans<100:
            ans+=100
        elif N ==2 and ans<10:
            ans+=10
        
        print(ans)
            
    else:
        print('-1')