### subroutines

def make_area(an, w)
  w[3] = an
  area = [w]

  start = w[0]

  while w[1] != start
    c1 = w[1]
    w1 = w[4]
    links1 = $links[c1]
    nl1 = links1.length

    wi = links1.index(w1)

    w = links1[(wi + nl1 - 1) % nl1]
    w[3] = an
    area << w
  end

  area
end

### main

while true
  $cn, $wn = gets.strip.split(' ').map{|s| s.to_i}
  break if $cn == 0 && $wn == 0

  $clmns = $cn.times.map{gets.strip.split(' ').map{|s| s.to_i}}

  $walls = $cn.times.map{[]}
  $links =  $cn.times.map{[]}

  $wn.times do
    c0, c1 = gets.strip.split(' ').map{|s| s.to_i}
    c0 -= 1
    c1 -= 1

    x0, y0 = $clmns[c0]
    x1, y1 = $clmns[c1]

    w0 = $walls[c0][c1] = [c0, c1, Math.atan2(y1 - y0, x1 - x0), nil]
    w1 = $walls[c1][c0] = [c1, c0, Math.atan2(y0 - y1, x0 - x1), nil]
    w0[4] = w1
    w1[4] = w0

    $links[c0] << w0
    $links[c1] << w1
  end
  #p $walls

  for c in (0...$cn)
    $links[c].sort!{|wa, wb| wa[2] <=> wb[2]}
  end
  #p $links

  an = 0
  $areas = []

  for ci in (0...$cn)
    for wi in $links[c].each_index
      w = $links[ci][wi]
      if w[3].nil?
        $areas << make_area(an, w)
        an += 1
      end
    end
  end
  #p an
  #$areas.each{|ar| p ar.map{|w| $clmns[w[0]]}}

  cimin = (0...$cn).min{|a, b| $clmns[a] <=> $clmns[b]}
  s_area = $links[cimin].last[3]
  #p cimin
  #p s_area

  dists = an.times.map{an + 1}
  dists[s_area] = 0
  visited = []
  visited[s_area] = 1

  q = [s_area]

  while ! q.empty?
    a0 = q.shift

    for w0 in $areas[a0]
      a1 = w0[4][3]
      if visited[a1].nil?
        visited[a1] = 1
        dists[a1] = dists[a0] + 1
        q << a1
      end
    end
  end

  puts dists.max
end