#!/usr/bin/python3

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

d = [ -1 for i in range(n) ]

ops = []
for i in range(m):
    ops.append(tuple(map(int, input().split())))


for op in ops:
    (s, c) = op
    if d[s - 1] >= 0 and d[s - 1] != c:
        print(-1)
        exit()
    else:
        d[s - 1] = c

for i in range(n):
    if d[i] == -1:
        if i == 0:
            d[i] = 1
        else:
            d[i] = 0
        
        
if n > 1 and d[0] == 0:
    print(-1)
else:
    print(''.join(map(str, d)))
