#include<iostream>
#include<complex>
#include<queue>
#include<algorithm>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

#define X real()
#define Y imag()

typedef long double D;
typedef complex<D> P;
struct L{P a, b;};
typedef vector<P> Pol;

const D EPS = 1e-8;
const D PI = acos(-1);

int sig(D a, D b = 0) {return a < b - EPS ? -1 : a > b + EPS ? 1 : 0;}
bool near(P a, P b) {return !sig(norm(a - b));}
namespace std {
  bool operator<(P a, P b) {return sig(a.X, b.X) ? a.X < b.X : a.Y < b.Y;}
  bool operator<(L a, L b) {return !near(a.a, b.a) ? a.a < b.a : a.b < b.b;}
}

D det(P a, P b) {return a.X * b.Y - a.Y * b.X;}

P vec(L a) {return a.b - a.a;}

enum CCW{FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16};
int ccw(P a, P b, P c) {
  if (near(a, c) || near(b, c)) return ON;
  int s = sig(det(b - a, c - a));
  if (s) return s > 0 ? LEFT : RIGHT;
  return (a < b) == (b < c) ? FRONT : (c < a) == (a < b) ? BACK : ON;
}

D arg(P base, P a, P b) {return arg((b - base) / (a - base));}

bool iLLs(L a, L b) {return sig(det(vec(a), vec(b)));}
bool iSS(L a, L b) {
  int cwa = ccw(a.a, a.b, b.a) | ccw(a.a, a.b, b.b);
  int cwb = ccw(b.a, b.b, a.a) | ccw(b.a, b.b, a.b);
  return ((cwa | cwb) & ON) || ((cwa & cwb) == (LEFT | RIGHT));
}

P pLL(L a, L b) {return a.a + vec(a) * (det(vec(b), b.a - a.a) / det(vec(b), vec(a)));}

D aPol(Pol vp) {D ret = 0; rep (i, vp.size()) ret += det(vp[i], vp[(i + 1) % vp.size()]); return ret / 2;}

vector<L> merge(vector<L> s) {
  rep (i, s.size()) if (s[i].b < s[i].a) swap(s[i].a, s[i].b);
  sort(s.begin(), s.end());
  rep (i, s.size()) rep (j, i) if (iSS(s[i], s[j]) && !iLLs(s[i], s[j])) {
    s[j].b = max(s[i].b, s[j].b);
    s.erase(s.begin() + i--);
    break;
  }
  return s;
}

vector<vector<int> > sArr(vector<L> s, vector<P> &vp) {
  s = merge(s);
  rep (i, s.size()) {
    vp.push_back(s[i].a);
    vp.push_back(s[i].b);
  }
  rep (i, s.size()) rep (j, i) if (iSS(s[i], s[j])) vp.push_back(pLL(s[i], s[j]));
  sort(vp.begin(), vp.end());
  vp.erase(unique(vp.begin(), vp.end(), near), vp.end());
  vector<vector<int> > g(vp.size());
  rep (i, s.size()) {
    vector<pair<D, int> > v;
    rep (j, vp.size()) if (ccw(s[i].a, s[i].b, vp[j]) == ON) {
      v.push_back(make_pair(norm(vp[j] - s[i].a), j));
    }
    sort(v.begin(), v.end());
    rep (j, v.size() - 1) {
      g[v[j + 1].second].push_back(v[j].second);
      g[v[j].second].push_back(v[j + 1].second);
    }
  }
  return g;
}

vector<Pol> dual(vector<L> s) {
  vector<P> vp;
  vector<vector<int> > edge = sArr(s, vp);
  vector<vector<bool> > used(edge.size());
  rep (i, edge.size()) rep (j, edge[i].size()) used[i].push_back(false);
  vector<Pol> vpol;
  rep (i, edge.size()) rep (j, edge[i].size()) if (!used[i][j]) {
    Pol pol;
    pol.push_back(vp[i]);
    used[i][j] = true;
    int pre = i, now = edge[i][j];
    while (now != i) {
      pol.push_back(vp[now]);
      D a = -4;
      int next = -1;
      rep (k, edge[now].size()) {
	D aa = arg(vp[now], (D)2 * vp[now] - vp[pre], vp[edge[now][k]]);
	if (!sig(aa, PI)) aa = -PI;
	if (a < aa) {
	  a = aa;
	  next = k;
	}
      }
      used[now][next] = true;
      pre = now;
      now = edge[pre][next];
    }
    vpol.push_back(pol);
  }
  return vpol;
}

int main() {
  while (true) {
    int c, w;
    cin >> c >> w;
    if (c == 0) break;
    vector<P> vp(c);
    rep (i, c) cin >> vp[i].X >> vp[i].Y;
    vector<L> vs(w);
    rep (i, w) {
      int s, t;
      cin >> s >> t;
      --s, --t;
      vs[i].a = vp[s];
      vs[i].b = vp[t];
    }
    vector<Pol> vpol = dual(vs);
    vector<int> edge[vpol.size()];
    rep (i, vpol.size()) rep (j, i) {
      rep (ii, vpol[i].size()) rep (jj, vpol[j].size()) {
	if (!near(vpol[i][ii], vpol[j][(jj + 1) % vpol[j].size()])) continue;
	if (!near(vpol[i][(ii + 1) % vpol[i].size()], vpol[j][jj])) continue;
	edge[i].push_back(j);
	edge[j].push_back(i);
      }
    }
    int dis[vpol.size()];
    rep (i, vpol.size()) dis[i] = 1e9;
    queue<pair<int, int> > que;
    rep (i, vpol.size()) if (aPol(vpol[i]) < 0) que.push(make_pair(i, 0));
    while (!que.empty()) {
      pair<int, int> now = que.front();
      que.pop();
      if (dis[now.first] <= now.second) continue;
      dis[now.first] = now.second;
      rep (i, edge[now.first].size()) {
	que.push(make_pair(edge[now.first][i], now.second + 1));
      }
    }
    int res = 0;
    rep (i, vpol.size()) res = max(res, dis[i]);
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1416