def calc(N, sc):
  integer = {}
  for s, c in sc:
    if s == 1 and c == 0:
      return -1
    elif integer.get(s) is None:
      integer[s]=c
    elif integer.get(s) != c:
      return -1

  r = []
  for s in range(1, N+1):
    if integer.get(s) is None:
      tmp = 0 if s > 1 else 1
      r.append(tmp)
    else:
      r.append(integer.get(s))
      
  return ''.join(map(str, r))
  
N, M = map(int, input().split())

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

print(calc(N, sc))