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

flag = False

used = []
d = [0]*n
for _ in range(m):
    s, c = map(int, input().split())
    if n > 1 and (s == 1 and c == 0):
        flag = True
    if s in used:
        flag = True
    else:
        d[s-1] = c
        used.append(s)
    
if flag:
    print(-1)
else:
    if d[0] == 0:
        d[0] = 1
    print(''.join(map(str, d)))