N,M = list(map(int,input().split()))
N_list=['']*N

for m in range(M):
    s_m , c_m = list(map(int,input().split()))
    
    if N != 0:
        if s_m ==1 and c_m ==0:
            N_list=[-1]
            break
    
    if N_list[s_m-1] == '':
        N_list[s_m-1] = c_m
    else:
        if N_list[s_m-1] != c_m:
            N_list=[-1]
            break
    
for n in range(len(N_list)):
    if N_list[n]=='':
        N_list[n]=0
        
if len(N_list)>1 and N_list[0]==0:
    N_list[0]=1

print(''.join(map(str,N_list)))
