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


li = ["#"]*N
A = "#"
if N==1:
    s,c = map(int,input().split())
    if not c==A and not c=="#":
        print(-1)
        break
    else:
        A=c
else:   
    if A == "#":
        print(0)
    else:
        print(int(A))
    

for i in range(M):
    s,c = map(int,input().split())
    if s==1 and c==0:
        print(-1)
        break

    if not li[s-1]=="#" and not li[s-1]==c:
        print(-1)
        break
    if li[s-1]=="#":
        li[s-1]=c
    
else:
    if li[0]=="#":
        li[0]=1
        
    num="".join(map(str,li))
    num_new=num.replace("#","0")
    print(num_new)

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


li = ["#"]*N
A = "#"
if N==1:
    for i in range(M):
        s,c = map(int,input().split())
        if not c==A and not A=="#":
            print(-1)
            exit()
        else:
            A=c
  
    if A == "#":
        print(0)
    else:
        print(int(A))
    exit()
    

for i in range(M):
    s,c = map(int,input().split())
    if s==1 and c==0:
        print(-1)
        break

    if not li[s-1]=="#" and not li[s-1]==c:
        print(-1)
        break
    if li[s-1]=="#":
        li[s-1]=c
    
else:
    if li[0]=="#":
        li[0]=1
        
    num="".join(map(str,li))
    num_new=num.replace("#","0")
    print(num_new)

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

memo = [0]*N

for i in range(M):
    s,c = map(int,input().split())
    if memo[s-1]==0:
        memo[s-1]=c
    elif s==1 and c==0:
        print(-1)
            break
    else:
        if not memo[s-1]==c:
            print(-1)
            break


else:
    if memo[0]==0:
        memo[0]=1
    
    counter = 0
    for iterration,k in enumerate(memo):
        counter += k*(10**(len(memo)-iterration-1))
    print(counter)

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


li = ["#"]*N
A = "#"
if N==1:
    for i in range(M):
        s,c = map(int,input().split())
        if not c==A and not A=="#":
            print(-1)
            exit()
        else:
            A=c
  
    if A == "#":
        print(0)
    else:
        print(int(A))
    exit()
    

for i in range(M):
    s,c = map(int,input().split())
    if s==1 and c==0:
        print(-1)
        break

    if not li[s-1]=="#" and not li[s-1]==c:
        print(-1)
        break
    if li[s-1]=="#":
        li[s-1]=c
    
else:
    if li[0]=="#":
        li[0]=1
        
    num="".join(map(str,li))
    num_new=num.replace("#","0")
    print(num_new)

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

memo = [0]*N

for i in range(M):
    s,c = map(int,input().split())
    if memo[s-1]==0:
        memo[s-1]=c
    else:
        if not memo[s-1]==c:
            print(-1)
            break

else:
    if memo[0]==0:
        memo[0]=1
    
    counter = 0
    for iterration,k in enumerate(memo):
        counter += k*(10**(len(memo)-iterration-1))
    print(counter)

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


li = ["#"]*N
A = "#"
if N==1:
    for i in range(M):
        s,c = map(int,input().split())
        if not c==A and not A=="#":
            print(-1)
            exit()
        else:
            A=c
  
    if A == "#":
        print(0)
    else:
        print(int(A))
    exit()
    

for i in range(M):
    s,c = map(int,input().split())
    if s==1 and c==0:
        print(-1)
        break

    if not li[s-1]=="#" and not li[s-1]==c:
        print(-1)
        break
    if li[s-1]=="#":
        li[s-1]=c
    
else:
    if li[0]=="#":
        li[0]=1
        
    num="".join(map(str,li))
    num_new=num.replace("#","0")
    print(num_new)