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

a = [ -1 ] * n

ret = 0
for _ in range(m):
  s, c = map( int, input().split() )
  if ( not ( a[ s - 1 ] in [ - 1, c ] ) ) or ( ( s == 1 ) and ( c == 0 ) ):
    ret = -1
    break
  a[ s - 1 ] = c
if ret != -1:
  ret = ""
  for i in range( n ):
    if a[i] == -1:
      if i == 0:
        a[ i ] = 1
      else:
        a[ i ] = 0
    ret += str( a[ i ] )
print( ret )

