import sys

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()

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

for i in range(1, 1000):
    x = str(i)
    if len(x) == N and all(x[s] == c for s, c in constraints):
        print(x)
        exit(0)

print(-1)
