Buggy python submission (verdict: Runtime Error):
N,M=[int(i) for i in input().split()]
# 二次元配列を得られる
A = []
answer=[0]*M
for i in range(M):
    A.append(list(map(int,input().split())))
j=0
for i in range(M):
    if answer[int(A[i][0])-1] == 0:
        answer[int(A[i][0])-1] = int(A[i][1])
    elif answer[int(A[i][0])-1] == int(A[i][1]):
        answer[int(A[i][0])-1] = int(A[i][1])
    else:
        print(-1)
        j=j+1
        break
seisu=0
if j==0 and answer[0]==0 and N!=1:
    j=j+1
    print(-1)
if j==0:
    for i in range(M):
        seisu=answer[i]*(10**(M-i-1))+seisu
    print(seisu)


Fixed submission:
N,M=[int(i) for i in input().split()]
# 二次元配列を得られる
A = []
answer=[-1]*N
for i in range(M):
    A.append(list(map(int,input().split())))
j=0
for i in range(M):
    if answer[int(A[i][0])-1] == -1:
        answer[int(A[i][0])-1] = int(A[i][1])
    elif answer[int(A[i][0])-1] == int(A[i][1]):
        answer[int(A[i][0])-1] = int(A[i][1])
    else:
        print(-1)
        j=j+1
        break
seisu=0
if j==0 and answer[0]==0 and N!=1:
    j=j+1
    print(-1)
if j==0 and (answer[0]==0 or answer[0]==-1) and N == 1:
    j=j+1
    print(0)
if j==0:
    for i in range(N):
        if answer[i]==-1:
            '''
            N = 5 case
            -1,7,-1,9,0
            ?7?90
            5 digits
            17090 
            '''
            if i == 0 :
                answer[0]=1
            else:
                answer[i]=0

        seisu=answer[i]*(10**(N-i-1))+seisu
    print(seisu)

Buggy python submission (verdict: Runtime Error):
N,M=[int(i) for i in input() .split()]
# 二次元配列を得られる
A = []
answer=[0]*M
for i in range(M):
    A.append(list(map(int,input().split())))
j=0
for i in range(M):
    if answer[int(A[i][0])-1] == 0:
        answer[int(A[i][0])-1] = int(A[i][1])
    elif answer[int(A[i][0])-1] == int(A[i][1]):
        answer[int(A[i][0])-1] = int(A[i][1])
    else:
        print(-1)
        j=j+1
        break
seisu=0
if j==0 and answer[0]==0:
    j=j+1
    print(-1)
if j==0:
    for i in range(M):
        seisu=answer[i]*(10**(M-i-1))+seisu
    print(seisu)


Fixed submission:
N,M=[int(i) for i in input().split()]
# 二次元配列を得られる
A = []
answer=[-1]*N
for i in range(M):
    A.append(list(map(int,input().split())))
j=0
for i in range(M):
    if answer[int(A[i][0])-1] == -1:
        answer[int(A[i][0])-1] = int(A[i][1])
    elif answer[int(A[i][0])-1] == int(A[i][1]):
        answer[int(A[i][0])-1] = int(A[i][1])
    else:
        print(-1)
        j=j+1
        break
seisu=0
if j==0 and answer[0]==0 and N!=1:
    j=j+1
    print(-1)
if j==0 and (answer[0]==0 or answer[0]==-1) and N == 1:
    j=j+1
    print(0)
if j==0:
    for i in range(N):
        if answer[i]==-1:
            '''
            N = 5 case
            -1,7,-1,9,0
            ?7?90
            5 digits
            17090 
            '''
            if i == 0 :
                answer[0]=1
            else:
                answer[i]=0

        seisu=answer[i]*(10**(N-i-1))+seisu
    print(seisu)

Buggy python submission (verdict: Runtime Error):
N,M=[int(i) for i in input() .split()]
# 二次元配列を得られる
A = []
answer=[0]*M
for i in range(M):
    A.append(list(map(int,input().split())))
j=0
for i in range(M):
    if answer[int(A[i][0])-1] == 0:
        answer[int(A[i][0])-1] = int(A[i][1])
    elif answer[int(A[i][0])-1] == int(A[i][1]):
        answer[int(A[i][0])-1] = int(A[i][1])
    else:
        print(-1)
        j=j+1
        break
seisu=0
if answer[0]==0:
    j=j+1
    print(-1)

if j==0:
    for i in range(M):
        seisu=answer[M-1-i]*(10**(M-i-1))+seisu
    print(seisu)


Fixed submission:
N,M=[int(i) for i in input().split()]
# 二次元配列を得られる
A = []
answer=[-1]*N
for i in range(M):
    A.append(list(map(int,input().split())))
j=0
for i in range(M):
    if answer[int(A[i][0])-1] == -1:
        answer[int(A[i][0])-1] = int(A[i][1])
    elif answer[int(A[i][0])-1] == int(A[i][1]):
        answer[int(A[i][0])-1] = int(A[i][1])
    else:
        print(-1)
        j=j+1
        break
seisu=0
if j==0 and answer[0]==0 and N!=1:
    j=j+1
    print(-1)
if j==0 and (answer[0]==0 or answer[0]==-1) and N == 1:
    j=j+1
    print(0)
if j==0:
    for i in range(N):
        if answer[i]==-1:
            '''
            N = 5 case
            -1,7,-1,9,0
            ?7?90
            5 digits
            17090 
            '''
            if i == 0 :
                answer[0]=1
            else:
                answer[i]=0

        seisu=answer[i]*(10**(N-i-1))+seisu
    print(seisu)