n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

flg = False
for i in range(10 ** (n - 1), 10 ** n):
    i = str(i)
    for s, c in sc:
        if int(i[s - 1]) == c:
            flg = True
        else:
            flg = False
            break
    else:
        break

if flg:
    print(i)
else:
    print(-1)