N, M = map(int, input().split())
if M == 0:
    if N == 1:
        print(0)
    else:
        print("1" + "0" * (N - 1))
    exit()
else:
    dic = {}
    for _ in range(M):
        s, c = map(int, input().split())
        if s == 1 and c == 0:
            print(-1)
            exit()
        n = dic.get(s)
        if n is not None and n != c:
            print(-1)
            exit()
        dic[s] = c

lst = [0] * N
for k, v in dic.items():
    lst[k - 1] = v

if len(lst) != 0 and lst[0] == 0:
    lst[0] = 1

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