Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
INF=10**18
A=[INF]*N
ans=0
for _ in range(M):
    s,c=map(int,input().split())
    s-=1
    if A[s]==INF:
        A[s]=c
    else:
        if A[s]!=c:
            print(-1)
            exit()
        else:
            continue

if A[0]==0:
    print(-1)
    exit()
elif A[0]==INF:
    A[0]=1

for i in range(1,3):
    if A[i]==INF:
        A[i]=0
A=[str(a) for a in A]
print(''.join(A))

Fixed submission:
N,M=map(int,input().split())
A=[]
if M==0:
    if N==1:
        print(0)
        exit()
    elif N==2:
        print(10)
        exit()
    else:
        print(100)
        exit()
        
else:
    for _ in range (M):
        s,c=map(int,input().split())
        A.append([s,c])

    for i in range(1000):
        i=str(i)
        if len(i)!=N:
            continue
        ans=0
        for X in A:
            x=X[0]
            y=X[1]
            x-=1
            if i[x]!=str(y):
                ans=1
                break
            else:
                continue
        if ans==0:
            print(i)
            exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
INF=10**18
A=[INF]*N
ans=0
for _ in range(M):
    s,c=map(int,input().split())
    s-=1
    if A[s]==INF:
        A[s]=c
    else:
        if A[s]!=c:
            print(-1)
            exit()

if A[0]==0:
    print(-1)
    exit()
elif A[0]==INF:
    A[0]=1

for i in range(1,3):
    if A[i]==INF:
        A[i]=0
A=[str(a) for a in A]
print(''.join(A))

Fixed submission:
N,M=map(int,input().split())
A=[]
if M==0:
    if N==1:
        print(0)
        exit()
    elif N==2:
        print(10)
        exit()
    else:
        print(100)
        exit()
        
else:
    for _ in range (M):
        s,c=map(int,input().split())
        A.append([s,c])

    for i in range(1000):
        i=str(i)
        if len(i)!=N:
            continue
        ans=0
        for X in A:
            x=X[0]
            y=X[1]
            x-=1
            if i[x]!=str(y):
                ans=1
                break
            else:
                continue
        if ans==0:
            print(i)
            exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
INF=10**18
A=[INF]*N
ans=0
for _ in range(M):
    s,c=map(int,input().split())
    s-=1
    if A[s]==INF:
        A[s]=c
    else:
        if A[s]!=c:
            print(-1)
            exit()

if A[0]==0:
    print(-1)
    exit()
elif A[0]==INF:
    A[0]==1

for i in range(1,3):
    if A[i]==INF:
        A[i]=0
A=[str(a) for a in A]
print(''.join(A))

Fixed submission:
N,M=map(int,input().split())
A=[]
if M==0:
    if N==1:
        print(0)
        exit()
    elif N==2:
        print(10)
        exit()
    else:
        print(100)
        exit()
        
else:
    for _ in range (M):
        s,c=map(int,input().split())
        A.append([s,c])

    for i in range(1000):
        i=str(i)
        if len(i)!=N:
            continue
        ans=0
        for X in A:
            x=X[0]
            y=X[1]
            x-=1
            if i[x]!=str(y):
                ans=1
                break
            else:
                continue
        if ans==0:
            print(i)
            exit()
print(-1)