n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

for i in range(1,10**n):
    i = str(i)
    flag = True
    if len(i) == n:
        for j in range(m):
            if i[sc[j][0]-1] != str(sc[j][1]):
                flag = False
        if flag:
            print(i)
            quit()

print(-1)