N,M = map(int,input().split())
s_list = list()
ans = [0 for i in range(N)]
flag = True
for i in range(M):
    s,c = map(int,input().split())
    
    if s==1 and c==0 and N!=1:
        flag = False
        
    if s in s_list:
        flag = False
    else:
        s_list.append(s)
        ans[s-1] = c
if flag ==False:
    print(-1)
else:
    if N != 1 and ans[0]==0:
        ans[0] = 1
    ans = [str(i) for i in ans]
    print(''.join(ans))