n,m = map(int,input().split())
ansl = [-1 for i in range(n)]
for _ in range(m):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and n != 1:
        print(-1)
        exit()
    if ansl[s-1] == -1 or ansl[s-1] == c:
        ansl[s-1] = c
    else:
        print(-1)
        exit()
if len(ansl) == 1:
    ansl[0] = 0
elif ansl[0] == 0:
    ansl[0] = 1
for idx, i in enumerate(ansl):
    if i == -1:
        ansl[idx] = 0

print("".join([str(i)for i in ansl]))
