import sys
n, m = map(int, input().split())

array = [-1] * n

for i in range(m):
  s,c = map(int, input().split())
  
  s -= 1
  
  if s == 0 and c == 0:
    print(-1)
    sys.exit(0)
  
  if array[s] == -1 or array[s] == c:
    array[s] = c
  else:
    print(-1)
    sys.exit(0)
    
if array[0] == -1:
  array[0] = 1
  
for i in range(n):
  if array[i] == -1:
    array[i] = 0

array = map(str, array)
print(''.join(array))