N, M = list(map(int, input().split()))

num = [0] * N


for _ in range(M):
    idx, c = list(map(int, input().split()))
    num[idx-1] = c

if N >= 2 and num[0] == 0:
    print(-1)
else:
    num = [str(x) for x in num]
    print(''.join(num))