n,m = map(int,input().split())
if m == 0:
    if n == 1:
        print(0)
        exit()
    if n == 2:
        print(10)
        exit()
    if n == 3:
        print(100)
        exit()
a = [-1]*n
for _ in range(m):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and n == 3:
        print(-1)
        exit()
    if s == 1 and c == 0 and n == 2:
        print(-1)
        exit()
    if a[s-1] == -1:
        a[s-1] = c
    else:
        if a[s-1] != c:
            print(-1)
            exit()

ans = ""
for i in range(n):
    if a[i] == -1:
        if i == 0 or i == 1:
            ans += "1"
        else:
            ans += "0"
    else:
        ans += str(a[i])
#print(ans)
if ans[0] == "0" and n > 1:
    print(-1)
else:
    print(ans)