n,m=map(int,input().split(' '))
ans=0
Alist = [-1]*n
for i in range(m):
    s,c = map(int,input().split(' '))
    if s == 1 and c == 0:
        ans = -1
    elif Alist[s-1] not in [-1,c]:
        ans = -1
    else:
        Alist[s-1] = c
if ans == -1:
    print(ans)
else:
    ans = ''
    if Alist[0] == -1:
        Alist[0] = 1
    for a in Alist:
        if a == -1:
            ans += '0'
        else:
            ans += str(a)
    print(ans)
    