n, m = list(map(int, input().split()))
sc = {}
for i in range(m):
    si, ci = list(map(int, input().split()))
    if (si in sc and sc[si] !=ci) or (si == 1 and ci == 0):
        print(-1)
        exit()
    sc[si] = ci

d = [1] + [0] * (n-1)

for si, ci in sc.items():
    d[si-1] = ci

s = ""
for c in d:
    s += str(c)
print(s)
