n, m = map(int, input().split())
d = {}
for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        print(-1)
        exit()
    if s in d:
        if d[s] != c:
            print(-1)
            exit()
    else:
        d[s] = c

ans = [0]*n
if n >= 2:
    ans[0] = 1
for i in range(n):
    if i+1 in d:
        ans[i] = d[i+1]
print(''.join(map(str, ans)))
