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

if nums[0] == -1:
    nums[0] = 1

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

ans = int(''.join(list(map(str, nums))))
print(ans)