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

ans = [0 for i in range(n)]

for i in range(m):
    r,s = map(int,input().split())
    if r-1 == 0 and s == 0:
        ans = [-1]
        break
    if ans[r-1] != 0 and ans[r-1] != s:
        ans = [-1]
        break
    ans[r-1] = s
if ans[0] == 0:
    ans[0] = 1
sum = ""
for i in range(len(ans)):
    sum += str(ans[i])
print(sum)