n, m = map(int, input().split())
n_list = []
for i in range(n):
    n_list.append(0)

for i in range(m):
    s, c = map(int, input().split())
    n_list[s-1] = c


if n_list.count(0) == n or n_list[0] == 0:
    print(-1)
else:
    ans_list = map(str, n_list)
    ans = ''.join(ans_list)
    print(ans)