N, M = [int(i) for i in input().split()]

d = [0 for i in range(N)]

for i in range(M):
    a, b = [int(i) for i in input().split()]
    d[a - 1] = b

if sum(d) == 0 or d[0] == 0:
    print(-1)
else:
    d = [str(i) for i in d]
    print(''.join(d))