import numpy as np
import sys

def solve(_n, _m):
  if _m == 0:
    ans = 0 if _n == 1 else 10 if _n == 2 else 100
    return ans

  restrict = np.zeros(_n, dtype=np.bool)
  num = np.full(_n, -1)
  for i in range(_m):
    _s, _c = map(int, input().split())
    if _s == 1 and _c == 0:
      return -1
    if not restrict[_s-1]:
      restrict[_s-1] = True
      num[_s-1] = _c
    else:
      if not num[_s-1] == _c:
        return -1
  return num

if __name__ == "__main__":
  _n, _m = map(int, input().split())

  ret = solve(_n, _m)
  if type(ret) is int:
    print(ret)
  else:
    ans = ""
    for ord,n in enumerate(ret):
      if ord == 0 and n == -1:
        ans += str(1)
      elif n == -1:
        ans += str(0)
      else:
        ans += str(n)

    print(int(ans))
