#!/usr/bin/env python3

N, M = map(int, input().split())


sc = []
for i in range(M):
    s, c = map(int, input().split())
    sc.append([s,c])


sc = sorted(sc)

start = 10 ** (N-1)
end = 10 ** N

ans = -1
for i in range(start, end):
    si = str(i)
    f = True
    for j in range(M):
        if si[sc[j][0]-1] != str(sc[j][1]):
            f = False
            break
    if f:
        ans = i
        break

    
print(ans)
