N, M = map(int, input().split())
res = ["*"]*N
flag = True
for i in range(M):
    s, c = input().split()
    if s == "1" and c == "0":
        flag = False
    if res[int(s)-1] != "*" and res[int(s)-1] != c:
        flag = False
    res[int(s)-1] = c

if flag:
    if res[0] == "*":
        res[0] = "1"
    print("".join(x if x != "*" else "0" for x in res))
else:
    print(-1)