n, m = map(int, input().split())
#ans = list("000")
x = [list(map(int, input().split())) for i in range(m)]
x = list(map(list, set(map(tuple, x))))
if n == 1:
    ans = list("0")
    for s, c in x:
        if s != 3:
            print(-1)
            exit()
        else:
            if ans[s-1] == "0":
                ans[s-1] = str(c)
            else:
                print("-1")
                exit()
    print("".join(ans))

if n == 2:
    ans = list("10")
    for s, c in x:
        if s == 1 or (s == 2 and c == 0):
            print(-1)
            exit()
        else:
            if ans[s-1] == "0":
                ans[s-1] = str(c)
            else:
                print("-1")
                exit()
    print("".join(ans))

if n == 3:
    ans = list("100")
    for s, c in x:
        if s == 1 and c == 0:
            print(-1)
            exit()
        else:
            if ans[s-1] == "0":
                ans[s-1] = str(c)
            else:
                print("-1")
                exit()
    print("".join(ans))