# coding: utf-8
# Your code here!
N, M = map(int,input().split())
ans = [-1]*N
Flg = True
for i in range(M):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and N != 1:
        Flg = False
        break
    elif ans[s-1] == -1:
        ans[s-1] = str(c)
    else:
        if ans[s-1] != str(c):
            Flg = False
            break
        
if Flg:
    for i in range(N):
        if ans[i] == -1 and i != 0:
            ans[i] = '0'
        elif ans[i] == -1 and i == 0:
            ans[i] = '1'
    print(''.join(ans))
else:
    print(-1)