n, m = map(int, input().split())
sc_list = [list(input().split()) for _ in range(m)]
for i in range(10**(n-1), 10**n):
    flag = True
    s = str(i)
    for sc in sc_list:
        if s[int(sc[0])-1] != sc[1]: 
            flag = False
            break
    if flag:
        print(i)
        exit()
print(-1)