N, M = map(int, input().split(' '))

conditions = []
for _ in range(M):
    s, c = input().split(' ')
    conditions.append((int(s) - 1, c))

lowest = int('1' + '0' * (N - 1))
highest = int('1' + '0' * N)

for n in range(lowest, highest):
    sn = str(n)
    for s, c in conditions:
        if sn[s] != c:
            break
    else:
        print(sn)
        break
else:
    print(-1)
