# coding: utf-8

n, m = map(int, input().split())

num = [-1 for i in range(n)]
jdge = 0
SC = [list(map(int, input().split())) for _ in range(m)]

for sc in SC:
    s = sc[0]
    c = sc[1]
    if num[s - 1] == -1 or num[s - 1] == c:
        num[s - 1] = c
    else:
        jdge = -1

if num[0] == -1:
    num[0] = 1
for i in range(n - 1):
    if num[i + 1] == -1:
        num[i + 1] = 0
if num[0] == 0:
    jdge = -1
ans = ''.join(map(str, num))

print(jdge if (jdge == -1) else (ans))
