N, M = map(int, input().split())
sc_list = []
for i in range(M):
    sc = list(map(int, input().split()))
    sc_list.append(sc)
ans = -1
for i in range(10**N):
    tmp = str(i)
    if len(tmp)==N:
        flag = True
        for j in sc_list:
            if int(tmp[j[0]-1])!=j[1]:
                flag = False
        if flag:
            ans = int(tmp)
            break
print(ans)