N, M = [int(i) for i in input().split()]
t = []
for i in range(M):
    t += [[int(i) for i in input().split()]]

for i in range(1, 1000):
    s = str(i)
    s
    if len(s) != N:
        continue
    isOK = True
    for it in t:
        if len(s) < it[0]:
            isOK = False
        else:
            isOK = isOK and (s[it[0]-1] == str(it[1]))
    if isOK:
        print(s)
        exit()
    
print(-1)
