n, m = [int(i) for i in input().split(' ')]
sc = [[int(i) for i in input().split(' ')] for j in range(m)]
sc = list(map(list, set(map(tuple, sc))))
s = [i[0] for i in sc]
c = [i[1] for i in sc]

fl1 = len(set(s)) != len(s)
if 1 in s:
  fl2 = c[s.index(1)]==0
else:
  fl2 = False

if fl1 | fl2:
  print('-1')
else:
  ans = ['0' for i in range(n)]
  if 1 not in s:
    ans[0] = '1'
  for i in sc:
    ans[i[0]-1] = str(i[1])
  print(''.join(ans))