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

sets = []
for i in range(M):
  s,c = input().split()
  sets.append((s,c))

start = 0
if N != 1:
  start = 10**(N-1)

for n in range(start,10**N):
  print(n)
  for s,c in sets:
    if str(n)[int(s)-1] == c:
      continue
    else:
      break
  else:
    print(n)
    break
else:
  print(-1)