n, m = map(int, input().split())
num_list = [0] * n

for _ in range(m):
    s, c = map(int, input().split())
    num_list[s-1] = c
    
number = int(''.join(str(i) for i in num_list))
if len(str(number)) == n:
    print(number)
elif number == 0:
    print(number)
else:
    print(-1)