import sys

line = sys.stdin.readline().strip()
n, m = map(int, line.split())
nums = [-1]*n
for _ in range(m):
    line = sys.stdin.readline().strip()
    pos, val = map(int, line.split())
    if n > 1 and pos == 1 and val == 0:
        print(-1)
        sys.exit(0)
    pos -= 1
    if nums[pos] != -1 and val != nums[pos]:
        print(-1)
        sys.exit(0)
    nums[pos] = val
if nums[0] == -1:
    nums[0] = 1
for i in range(1, n):
    if nums[i] == -1:
        nums[i] = 0
print("".join(map(str,nums)))