op = [list(map(int, inp.split())) for inp in open(0)]
n = op[0][0]
m = op[0][1]
list_s = []
list_c = []
for i in range(1, m + 1):
  s = op[i][0]
  c = op[i][1]
  list_s.append(s)
  list_c.append(c)
res = -1
for num in range(10 ** (n - 1), 10 ** n):
  list_ = [int(num_) for num_ in list(str(num))]
  flag = True
  for i in range(m):
    if list_[list_s[i] - 1] == list_c[i]:
      pass
    else:
      flag = False
  if flag:
    res = num
    break
print(res)