n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]

for i in range(m):
    for j in range(m):
        if i != j and lst[i][0] == lst[j][0] and lst[i][1] != lst[j][1]:
            print(-1)
            exit()

ans = "0" * n
for l in lst:
    if l[0] == 1 and l[1] == 0:
        print(-1)
        exit()
    ans = ans[: l[0] - 1] + str(l[1]) + ans[l[0]: ]

if ans[0] == "0":
    ans = "1" + ans[1: ]

print(ans)