import sys
range = xrange
input = raw_input

inp = [int(x) for x in sys.stdin.read().split()]; ii = 0

n = inp[ii]; ii += 1
m = inp[ii]; ii += 1

for x in range(1000):
    ii = 2
    y = str(x)
    if len(y) != n:
        continue
    
    for _ in range(m):
        s = inp[ii]; ii += 1
        c = inp[ii]; ii += 1
        if y[s - 1] != chr(c + 48):
            break
    else:
        print y
        break
    continue
else:
    print -1
