import math
N, M = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(M)]
for n in range(10**(N-1), 10**N):
    nstr = str(n)
    flg = 0
    for i in range(M):
        if nstr[sc[i][0]-1] != str(sc[i][1]):
            flg = 1
            break
    if flg==0:
        print(n)
        exit()
print(-1)
