n, m = [int(v) for v in input().split()]
query = [tuple(int(v) for v in input().split()) for _ in range(m)]

res = [None] * n

for s, c in query:
    s -= 1
    if res[s] is None:
        if n > 1 and c == 0 and s == 0:
            res = None
            break
        res[s] = c
    elif res[s] == c:
        pass
    else:
        res = None
        break

if res is None:
    print("-1")
else:
    if res[0] is None:
        res[0] = 1
    res = [0 if v is None else v for v in res]
    print("".join(str(v) for v in res))