N, M = map(int, input().split())
xs = [None] * N
for _ in range(M):
    s, c = map(int, input().split())
    if xs[s - 1] is None:
        xs[s - 1] = c
    elif xs[s - 1] != c:
        print(-1)
        break
else:
    for i in range(N):
        if xs[i] is None:
            xs[i] = 0 if 0 < i else 1
    ans = ''.join(map(str, xs))
    if ans.startswith('0'):
        print(-1)
    else:
        print(ans)