n, m = map(int, input().split())
constrict = [list(map(int, input().split())) for _ in range(m)]
flag = False
for i in range(10**(n-1), 10**n):
    is_correct = True
    for j, k in constrict:
        if str(i)[j-1] != str(k):
            is_correct = False
            break
    if is_correct:
        flag = True
        print(i)
        break
if not flag:
    print(-1)
        