n, m = map(int, input().split())
number = ['x' for i in range(n)]
flag = True
for i in range(m):
    s, c = map(int, input().split())
    if n != 1 and s == 1 and c ==0:
        flag = False
    if number[s - 1] != 'x' and  number[s - 1] != c:
        flag = False
    number[s - 1] = c

if number[0] == 'x':
    number[0] = 1
for i in range(1, n):
    if number[i] == 'x':
        number[i] = 0

if flag:
    for i in range(n):
        print(number[i], end='')
else:
    print(-1)