# -*- coding: utf-8 -*-

n, m = map(int, input().split())
l = [0]*n
for i in range(m):
    s, c = map(int, input().split())
    l[s-1] = c
if l[0] == 0:
    print(-1)
    exit()
ans = 0
tmp = 1
for i in reversed(l):
    ans += tmp*i
    tmp *= 10
print(ans)