import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n,m = map(int, input().split())
v = [[] for _ in range(m)]
for i in range(m):
    s, c = map(int, input().split())
    v[i].append(s)
    v[i].append(c)

ans = [0] * n
for i in range(m):
    k = n - v[i][0]
    ans[k] = v[i][1]

num = 0
for i in range(n - 1, -1, -1):
    num += ans[i] * 10**i

if len(str(num)) != n:
    print(-1)
else:
    print(num)
