N, M = map(int, input().split())
l_same = [-1, -1, -1]
if N == 1:
  s_num = '0'
else:
	s_num = '1' + '0' * (N - 1)
for i in range(M):
  s, c = map(int, input().split())
  if N != 1 and (s == 1 and c == 0):
    ans = -1
    break
  elif l_same[s - 1] != -1 and l_same[s - 1] != c:
    ans = -1
    break
  else:
    l_same[s - 1] = c
    s_num = s_num[0:s - 1] + str(c) +  s_num[s:]
    ans = int(s_num)
print(ans)
  