N, M = map(int, input().split())

ans = ["0" for _ in range(N)]
change = []
for _ in range(M):
    s_i, c_i = map(int, input().split())
    if s_i not in change:
        ans[s_i - 1] = str(c_i)
    else:
        print(-1)
        exit()
if ans[0] != "0":
    print("".join(ans))
else:
    print(-1)