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

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;
typedef pair<P, P> L;
typedef vector<P> Pol;

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

int sig(D r) {return (r < -EPS) ? -1 : (r > EPS) ? 1 : 0;}
bool eq(D a, D b) {return abs(a - b) < EPS;}
bool near(P a, P b) {return abs(a - b) < EPS;}

// 内積
D dot(P a, P b) {return a.X * b.X + a.Y * b.Y;}
// 外積
D det(P a, P b) {return a.X * b.Y - a.Y * b.X;}

// 線分のベクトル
P vec(L a) {return a.second - a.first;}

// 線分abに対する点xの位置
enum CCW{FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16};
int ccw(L s, P p) {
  P a = vec(s);
  p -= s.first;
  D cr = det(a, p);
  if (eq(cr, 0)) {
    if (sig(dot(a, p)) < 0) return BACK;
    if (sig(norm(a) - norm(p)) < 0) return FRONT;
    return ON;
  }
  return (cr > 0) ? LEFT : RIGHT;
}

// 角度
D ang(P p) {D theta = arg(p); return sig(theta - PI) < 0 ? theta : -PI;}
// 有向角度
D ang(P base, P a, P b) {return ang((b - base) / (a - base));}

// 射影
P proj(P a, P b) {return a * dot(a, b) / norm(a);}
P perp(L l, P p) {return l.first + proj(vec(l), p - l.first);}
P refl(L l, P p) {return perp(l, p) * (D)2 - p;}

// 交差判定
bool iLL(L a, L b) {return !eq(det(vec(a), vec(b)), 0);}
bool eqL(L a, L b) {return !iLL(a, b) && eq(det(vec(a), b.first - a.first), 0);}
bool iLS(L a, L b) {return sig(det(vec(a), b.first - a.first)) * sig(det(vec(a), b.second - a.first)) <= 0;}
bool iLSs(L a, L b) {return sig(det(vec(a), b.first - a.first)) * sig(det(vec(a), b.second - a.first)) < 0;}
bool iSS(L a, L b) {
  int cwa = ccw(a, b.first) | ccw(a, b.second);
  int cwb = ccw(b, a.first) | ccw(b, a.second);
  return ((cwa | cwb) & ON) || ((cwa & cwb) == (LEFT | RIGHT));
}
bool iSSs(L a, L b) {return ((ccw(a, b.first) | ccw(a, b.second)) & (ccw(b, a.first) | ccw(b, a.second))) == (LEFT | RIGHT);}

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

// 距離
D dLP(L l, P x) {return abs(det(vec(l), x - l.first)) / abs(vec(l));}
D dSP(L s, P x) {
  if (sig(dot(vec(s), x - s.first)) <= 0) return abs(x - s.first);
  if (sig(dot(-vec(s), x - s.second)) <= 0) return abs(x - s.second);
  return dLP(s, x);
}
D dLL(L a, L b) {return iLL(a, b) ? 0 : dLP(a, b.first);}
D dLS(L a, L b) {return iLS(a, b) ? 0 : min(dLP(a, b.first), dLP(a, b.second));}
D dSS(L a, L b) {return iSS(a, b) ? 0 : min(min(dSP(a, b.first), dSP(a, b.second)), min(dSP(b, a.first), dSP(b, a.second)));}

// 比較関数
namespace std {
  bool operator<(P a, P b) {return eq(a.X, b.X) ? a.Y < b.Y : a.X < b.X;}
}
L sortBase;
bool lessArg(P a, P b) {
  D ang1 = ang(sortBase.first, sortBase.second, a);
  D ang2 = ang(sortBase.first, sortBase.second, b);
  return eq(ang1, ang2) ? norm(a) > norm(b) : ang1 < ang2;
}

// 円
struct C{
  P c; D r;
  C() {}
  C(P c, D r) : c(c), r(r) {}
};

// 2円の位置関係
enum RELATION{SAME = 1, CONTAIN = 2, OVER = 4, NO_CROSS = 8, ONE_CROSS = 16, ONE_CONTAIN_CROSS = 32, ONE_OVER_CROSS = 64, TWO_CROSS = 128};
int cRel(C c1, C c2) {
  D d = abs(c1.c - c2.c);
  if (near(c1.c, c2.c) && eq(c1.r, c2.r)) return SAME;
  if (sig(d - (c1.r - c2.r)) < 0) return OVER;
  if (sig(d - (c2.r - c1.r)) < 0) return CONTAIN;
  if (eq(d, c1.r - c2.r)) return ONE_OVER_CROSS;
  if (eq(d, c2.r - c1.r)) return ONE_CONTAIN_CROSS;
  if (eq(d, c1.r + c2.r)) return ONE_CROSS;
  if (sig(d - (c1.r + c2.r)) > 0) return NO_CROSS;
  return TWO_CROSS;
}

// 点が円に含まれるか
bool iCP(C c, P p) {return sig(abs(p - c.c) - c.r) <= 0;}
// 交差判定
bool iCL(C c, L l) {return sig(c.r - dLP(l, c.c)) >= 0;}
// 円と交差せず完全に含まれても良い場合は&&以降を削除
bool iCS(C c, L s) {return iCL(c, s) && sig(c.r - max(abs(s.first - c.c), abs(s.second - c.c))) <= 0;}
bool iCC(C a, C b) {return sig(abs(a.c - b.c) - abs(a.r - b.r) >= 0) && sig(abs(a.c - b.c) - a.r - b.r) <= 0;}

// 交点
pair<P, P> pCC(C a, C b) {
  D x = (norm(a.c - b.c) + a.r * a.r - b.r * b.r) / (2 * abs(a.c - b.c));
  P e = (b.c - a.c) / abs(b.c - a.c);
  P y = e * P(0, sqrt(max(a.r * a.r - x * x, (D)0)));
  return make_pair(a.c + e * x - y, a.c + e * x + y);
}
pair<P, P> pCL(C c, L l) {
  P x = perp(l, c.c);
  P y = vec(l) / abs(vec(l)) * sqrt(max(c.r * c.r - norm(x - c.c), (D)0));
  return make_pair(x - y, x + y);
}

// 角の内外判定 角abの内部にあれば正、辺上は0、外部は負
int sAP(P a, P b, P c) {return sig(det(a, c)) - sig(det(b, c)) - sig(det(a, b));}

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

// 三角形の面積
D aTri(D a, D b, D c){
  D s = (a + b + c) / 2;
  return sqrt(max(s * (s - a) * (s - b) * (s - c), (D)0));
}

// 多角形の内外判定 内部:1、周上:0、外部:-1
int sGP(Pol pol, P p) {
  int side = -1;
  rep (i, pol.size()) {
    P p0 = pol[i] - p, p1 = pol[(i + 1) % pol.size()] - p;
    if (sig(det(p0, p1)) == 0 && sig(dot(p0, p1)) <= 0) return 0;
    if (p0.Y > p1.Y) swap(p0, p1);
    if (sig(p0.Y) <= 0 && 0 < sig(p1.Y) && sig(det(p0, p1)) > 0) side *= -1;
  }
  return side;
}

// 凸包
Pol convexHull(Pol p) {
  int m = 0;
  vector<P> q(p.size() * 2);
  sort(p.begin(), p.end());
  for (int i = 0; i < int(p.size()); q[m++] = p[i++]) for (; m > 1 && sig(det(q[m - 1] - q[m - 2], p[i] - q[m - 2])) <= 0; --m);
  for (int i = p.size() - 2, r = m; i >= 0; q[m++] = p[i--]) for (; m > r && sig(det(q[m - 1] - q[m - 2], p[i] - q[m - 2])) <= 0; --m);
  q.resize(m - 1);
  return q;
}

// 凸包カット
Pol convexCut(Pol p, L l) {
  vector<P> q;
  rep (i, p.size()) {
    if (ccw(l, p[i]) & (LEFT | BACK | ON | FRONT)) q.push_back(p[i]);
    if (iLSs(l, L(p[i], p[(i + 1) % p.size()]))) q.push_back(pLL(l, L(p[i], p[(i + 1) % p.size()])));
  }
  return q;
}

// 線分をマージする
vector<L> merge(vector<L> s) {
  rep (i, s.size()) if (s[i].second < s[i].first) swap(s[i].first, s[i].second);
  sort(s.begin(), s.end());
  rep (i, s.size()) rep (j, i) if (iSS(s[i], s[j]) && !iLL(s[i], s[j])) {
    s[j].second = max(s[i].second, s[j].second);
    s.erase(s.begin() + i--);
    break;
  }
  return s;
}

// 線分アレンジメント 隣の点への辺のみを持つ
pair<vector<P>, vector<vector<int> > > sArr(vector<L> s) {
  s = merge(s);
  vector<P> vp;
  rep (i, s.size()) {
    vp.push_back(s[i].first);
    vp.push_back(s[i].second);
  }
  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], vp[j]) == ON) v.push_back(make_pair(norm(vp[j] - s[i].first), 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 make_pair(vp, g);
}

vector<Pol> dual(vector<L> s) {
  pair<vector<P>, vector<vector<int> > > arr = sArr(s);
  vector<P> vp = arr.first;
  vector<vector<int> > edge = arr.second;
  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 = ang(vp[now], (D)2 * vp[now] - vp[pre], vp[edge[now][k]]);
	if (eq(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 && w == 0) break;
    vector<P> vp(c);
    vector<L> vl(w);
    rep (i, c) cin >> vp[i].X >> vp[i].Y;
    rep (i, w) {
      int s, t;
      cin >> s >> t;
      --s; --t;
      vl[i] = L(vp[s], vp[t]);
    }
    vector<Pol> vpol = dual(vl);
    vector<int> dis;
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
    rep (i, vpol.size()) {
      if (aPol(vpol[i]) < 0) {
	que.push(make_pair(0, i));
      }
      dis.push_back(int(1e9));
    }
    vector<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()]) && near(vpol[i][(ii + 1) % vpol[i].size()], vpol[j][jj])) {
	edge[i].push_back(j);
	edge[j].push_back(i);	
      }
    }
    while (!que.empty()) {
      pair<int, int> now = que.top();
      que.pop();
      if (dis[now.second] <= now.first) continue;
      dis[now.second] = now.first;
      rep (i, edge[now.second].size()) que.push(make_pair(now.first + 1, edge[now.second][i]));
    }
    int res = 0;
    rep (i, dis.size()) res = max(res, dis[i]);
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1420