N, M = [int(i) for i in input().split()]
v = ['x' for n in range(N)]
e = False
for m in range(M):
    s, c = [int(i) for i in input().split()]
    if e:
        continue
    if v[s-1] != 'x' and v[s-1]!=str(c):
        e = True
    else:
        v[s-1] = str(c)

if e:
    print(-1)
    exit()

r = []
fd = True
for d in v:
    if d == 'x':
        if fd:
            r.append('1')
        else:
            r.append('0')
    else:
        r.append(d)
    fd = False

rv = int("".join(r))

if len(str(rv))!=N:
    print("".join(r))
    print(-1)
else:
    print("".join(r))