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

nums = [-1]*n

if m==0:
    print(0)
    exit()

for _ in range(m):
    s, c = map(int, input().split())
    if n > 1 and s == 1 and c == 0:
        print(-1)
        exit()
    if nums[s-1] != -1:
        if nums[s-1] != c:
            print(-1)
            exit()
    nums[s-1] = c

for _ in range(n):
    if nums[_] == -1:
        if _==0:
            nums[_] = 1
        else:
            nums[_] = 0

print(''.join([str(_) for _ in nums]))
