n, m = map(int, input().split())

list_A = []
for i in range(m):
    list_A.append(list(map(int, input().split())))

end = int("9"*n)
start = int("1" + "0"*(n-1))
for i in range(start, end + 1):
    i = str(i)
    #個々の条件をクリアできるか
    flag = 0
    for j in list_A:

        #一つの条件の確認
        a, b = j
        if i[a-1] != str(b):
            break

        flag += 1

    if flag == len(list_A):
        print(int(i))
        exit()
print(-1)

