n, m = map(int, input().split())
s = []
c = []
for _ in range(m):
    s1, c1 = [int(_) for _ in input().split()]
    s.append(s1)
    c.append(c1)

num_list = []
for _ in range(n):
    num_list.append(0)

for _ in range(m):
    num_list[s[_]-1] = c[_]

if num_list[0] == 0:
    print(-1)
else:
    num = ''.join(map(str, num_list))
    print(num)
