N, M = map(int, input().split())
sc = sorted(set([tuple(map(int, input().split()))
                 for i in range(M)]))
ans = 0
position = 0
for s_c_i in sc:
    if (s_c_i == (1, 0) and N > 1) or s_c_i[0] == position:
        ans = -1
        break
    position = s_c_i[0]
    ans += (10**(N-position))*s_c_i[1]
if ans > 0 and ans < 10**(N-1):
    ans += 10**(N-1)
print(ans)