N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]
ans = []
SC = sorted(SC)

for x, item in enumerate(SC):
    if len(ans) + 1 < item[0]:
        if len(ans) == 0:
            ans.append(1)
        for y in range(item[0] -len(ans) - 1):
            ans.append(0)
    if len(ans) + 1 == item[0]:
        ans.append(item[1])
    elif len(ans) == item[0]:
        continue

if len(ans) < N:
    for x in range(N - len(ans)):
        ans.append(0)

if ans(0) == 0 and len(ans) != 0:
    print(-1)
else:
    ans = map(str, ans)
    print("".join(ans))