N, M = map(int, input().split())
Q = []
for i in range(M):
    Q.append(tuple(map(int, input().split())))

for i in range(10**(N-1), 10**N):
    s = str(i)
    flg = True
    for q in Q:
        if s[q[0]-1] != str(q[1]):
            flg = False
    if flg:
        print(i)
        exit()

print(-1)
