n, m = map(int, input().split())
sc = []
ans = [None for _ in range(n)]
for _ in range(m): sc.append([int(x) for x in input().split()])
for s, c in sc:
    s -= 1
    if s == 0 and c == 0:
        ans = -1
        break
    elif ans[s] is None: ans[s] = c
    elif ans[s] is not None and ans[s] != c:
        ans = -1
        break
if ans == -1: print(ans)
else:
    for i in range(n):
        if i == 0 and ans[i] is None: ans[i] = 1
        elif ans[i] is None: ans[i] = 0
    a = ""
    for i in ans:
        a += str(i)
    print(a)