from functools import reduce
n, m = map(int, input().split())
list = []
for i in range(0, n):
    list.append(0)

for j in range(0, m):
    s, c = map(int, input().split())
    list[s-1] = int(c)

if list[0] == 0:
    print("-1")
else:
    ans = reduce( lambda a,b:10*a+b, list)
    print(ans)