n,m = map(int,input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

ans = ['0'] * n
ans[0] = '1'
ok = True
rep = {}

for s, c in sc:
    ans[s-1] = str(c)
    if s in rep and rep[s] != c:
        ok = False
    rep[s] = c

if ans[0] == '0':
    ok = False

if ok:
    print("".join(ans))
else:
    print("-1")
