n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))
for i in range(10 ** (n - 1), 10 ** n):
    test = str(i)
    flag = True
    for j in range(m):
        s = sc[j][0]
        c = sc[j][1]
        if test[s - 1] != str(c):
            flag = False
            break
    if flag == False:
        continue
    else:
        print(i)
        break
else:
    print(-1)