n, m = map(int, input().split())
nums = [99] * n

for _ in range(m):
    n1, n2 = map(int, input().split())
    nums[n1-1] = min(nums[n1-1], n2)

if nums[0] not in [99, 0]:
    print("".join([str(x) if x!=99 else "0" for x in nums]))
else:
    print(-1)