n, m = map(int, input().split())
ans = [-1] * n
flag = 0
for i in range(m):
    s, c = map(int, input().split())
    if ans[s-1] == -1:
        ans[s-1] = c
    elif ans[s-1] != c:
        flag = 1
if flag > 0:
    print(-1)
else:
    for i in range(n):
        if ans[i] == -1:
            if i == 0:
                ans[i] = 1
            else:
                ans[i] = 0
    p = map(str, ans)
    d = "".join(p)
    if d == "00" or d == "000":
        print(-1)
    else:
        print(d)