N, M = map(int, input().split())
r = list([None]*N)
for i in range(M):
    s, c = map(int, input().split())
    if r[s-1] is not None:
        print("-1")
        exit()
    r[s-1] = c

if N > 1 and r[0] == 0:
        print("-1")
        exit()

for i in range(len(r)):
    if r[i] is None:
        if N > 1 and i == 0:
            r[i] = 1
        else:
            r[i] = 0

print("".join(map(str, r)))