Problem: Taro got a driver’s license with a great effort in his campus days, but unfortunately there had been no opportunities for him to drive. He ended up obtaining a gold license.

One day, he and his friends made a plan to go on a trip to Kyoto with you. At the end of their meeting, they agreed to go around by car, but there was a big problem; none of his friends was able to drive a car. Thus he had no choice but to become the driver.

The day of our departure has come. He is going to drive but would never turn to the right for fear of crossing an opposite lane (note that cars keep left in Japan). Furthermore, he cannot U-turn for the lack of his technique. The car is equipped with a car navigation system, but the system cannot search for a route without right turns. So he asked to you: “I hate right turns, so, could you write a program to find the shortest left-turn-only route to the destination, using the road map taken from this navigation system?”



Input

The input consists of multiple data sets. The first line of the input contains the number of data sets. Each data set is described in the format below:


m n
name1 x1 y1
...
namem xm ym
p1 q1
...
pn qn
src dst


m is the number of intersections. n is the number of roads. namei is the name of the i-th intersection. (xi, yi) are the integer coordinates of the i-th intersection, where the positive x goes to the east, and the positive y goes to the north. pj and qj are the intersection names that represent the endpoints of the j-th road. All roads are bidirectional and either vertical or horizontal. src and dst are the names of the source and destination intersections, respectively.

You may assume all of the followings:

* 2 ≤ m ≤ 1000, 0 ≤ xi ≤ 10000, and 0 ≤ yi ≤ 10000;
* each intersection name is a sequence of one or more alphabetical characters at most 25 character long;
* no intersections share the same coordinates;
* no pair of roads have common points other than their endpoints;
* no road has intersections in the middle;
* no pair of intersections has more than one road;
* Taro can start the car in any direction; and
* the source and destination intersections are different.



Note that there may be a case that an intersection is connected to less than three roads in the input data; the rode map may not include smaller roads which are not appropriate for the non-local people. In such a case, you still have to consider them as intersections when you go them through.

Output

For each data set, print how many times at least Taro needs to pass intersections when he drive the route of the shortest distance without right turns. The source and destination intersections must be considered as “passed” (thus should be counted) when Taro starts from the source or arrives at the destination. Also note that there may be more than one shortest route possible.

Print “impossible” if there is no route to the destination without right turns.

Example

Input

2 1
KarasumaKitaoji 0 6150
KarasumaNanajo 0 0
KarasumaNanajo KarasumaKitaoji
KarasumaKitaoji KarasumaNanajo
3 2
KujoOmiya 0 0
KujoAburanokoji 400 0
OmiyaNanajo 0 1150
KujoOmiya KujoAburanokoji
KujoOmiya OmiyaNanajo
KujoAburanokoji OmiyaNanajo
10 12
KarasumaGojo 745 0
HorikawaShijo 0 870
ShijoKarasuma 745 870
ShijoKawaramachi 1645 870
HorikawaOike 0 1700
KarasumaOike 745 1700
KawaramachiOike 1645 1700
KawabataOike 1945 1700
KarasumaMarutamachi 745 2445
KawaramachiMarutamachi 1645 2445
KarasumaGojo ShijoKarasuma
HorikawaShijo ShijoKarasuma
ShijoKarasuma ShijoKawaramachi
HorikawaShijo HorikawaOike
ShijoKarasuma KarasumaOike
ShijoKawaramachi KawaramachiOike
HorikawaOike KarasumaOike
KarasumaOike KawaramachiOike
KawaramachiOike KawabataOike
KarasumaOike KarasumaMarutamachi
KawaramachiOike KawaramachiMarutamachi
KarasumaMarutamachi KawaramachiMarutamachi
KarasumaGojo KawabataOike
8 9
NishikojiNanajo 0 0
NishiojiNanajo 750 0
NishikojiGojo 0 800
NishiojiGojo 750 800
HorikawaGojo 2550 800
NishiojiShijo 750 1700
Enmachi 750 3250
HorikawaMarutamachi 2550 3250
NishikojiNanajo NishiojiNanajo
NishikojiNanajo NishikojiGojo
NishiojiNanajo NishiojiGojo
NishikojiGojo NishiojiGojo
NishiojiGojo HorikawaGojo
NishiojiGojo NishiojiShijo
HorikawaGojo HorikawaMarutamachi
NishiojiShijo Enmachi
Enmachi HorikawaMarutamachi
HorikawaGojo NishiojiShijo
0 0


Output

2
impossible
13
4

Solution (in CPP):

Solution:
/*
02:08 - 
 */

#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<unordered_map>
#include<queue>
#include<climits>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 2000
#define pow2(a) ((a)*(a))
#define EPS 1e-7
#define equals(a,b) (fabs((a)-(b)) < EPS)

using namespace std;

struct Point{
  double x,y;
  Point(double x=IINF,double y=IINF):x(x),y(y){}
  Point operator - (const Point& a)const { return {x-a.x,y-a.y}; }
};

struct Edge{
  int from,to;
  double dist;
  Edge(int from=IINF,int to=IINF,double dist=IINF):from(from),to(to),dist(dist){}
};

struct Data{
  int pre,cur,cost;
  double dist;
  Data(int pre=IINF,int cur=IINF,int cost=IINF,double dist=IINF):pre(pre),cur(cur),cost(cost),dist(dist){}
  bool operator < (const Data& a) const {
    if(equals(dist,a.dist))return cost > a.cost;
    return dist > a.dist;
  }
};

inline double getDist(Point a,Point b){ return sqrt(pow2(a.x-b.x)+pow2(a.y-b.y)); }
inline double cross(Point a,Point b){ return a.x*b.y-a.y*b.x; }


vector<Edge> G[MAX];
vector<Point> ps;
double mindist[MAX][MAX];//mindist[pre_node][cur_node] 
int    mincost[MAX][MAX];
int E,V,sp,gp;

bool cmp(const Edge& a,const Edge& b){
  Point A = ps[a.to]-ps[a.from], B = ps[b.to]-ps[b.from];
  return atan2(A.y,A.x) < atan2(B.y,B.x);
}

void compute(){

  rep(i,V)rep(j,V){
    mindist[i][j] = IINF;
    mincost[i][j] = IINF;
  }
  priority_queue<Data> Q;
  rep(i,G[sp].size()){
    mindist[sp][G[sp][i].to] = G[sp][i].dist;
    mincost[sp][G[sp][i].to] = 2;
    Q.push(Data(sp,G[sp][i].to,2,G[sp][i].dist));
  }

  while(!Q.empty()){
    Data data = Q.top(); Q.pop();
    Point cp = ps[data.cur];
    Point pp = ps[data.pre];
    //cout << "cur | (" << data.pre << "," << data.cur << "," << data.cost << "," << data.dist << ")" << endl;
    if(data.cur == gp){
      cout << data.cost << endl;
      return;
    }

    rep(i,G[data.cur].size()){
      //cout << "cand " << G[data.cur][i].to << endl;
      //if(G[data.cur][i].from == data.cur && G[data.cur][i].to == data.pre){
      //int next = (i+(int)G[data.cur].size()-1)%(int)G[data.cur].size();
      int next = i;
	Point np = ps[G[data.cur][next].to];
	//if(equals(pp.x,np.x) || equals(pp.y,np.y))continue;
	//cout << "cand is ok" << endl;
	if(G[data.cur][next].to == data.pre)continue;
	//cout << G[data.cur][next].to << "here" << endl;
	if(cross(cp-pp,np-pp) < -EPS)continue;
	//cout << "ok" << endl;
	double dist = G[data.cur][next].dist;
	if(equals(mindist[data.cur][next],data.dist+dist)){
	  if(mincost[data.cur][G[data.cur][next].to] > data.cost+1){
	    //cout << "go next " << data.cur << " to " << G[data.cur][next].to << endl;
	    mincost[data.cur][G[data.cur][next].to] = data.cost+1;
	    Q.push(Data(data.cur,G[data.cur][next].to,data.cost+1,data.dist+dist));
	  }
	} else if(mindist[data.cur][G[data.cur][next].to] > data.dist+dist){
	  //cout << "go next " << data.cur << " to " << G[data.cur][next].to << endl;
	  mindist[data.cur][G[data.cur][next].to] = data.dist + dist;
	  mincost[data.cur][G[data.cur][next].to] = data.cost + 1;
	  Q.push(Data(data.cur,G[data.cur][next].to,data.cost+1,data.dist+dist));
	}
	//}
    }
  }

  cout << "impossible" << endl;

}

int main(){
  while(cin >> V >> E,V|E){
    unordered_map<string,int> getIndex;
    int x,y;
    string name,p,q;
    ps.clear();
    rep(i,V)G[i].clear();

    rep(i,V){
      cin >> name >> x >> y;
      getIndex[name] = (int)ps.size();
      ps.push_back(Point(x,y));
    }
    assert(getIndex.size() == ps.size());

    rep(i,E){
      cin >> p >> q;
      int node1 = getIndex[p], node2 = getIndex[q];
      G[node1].push_back(Edge(node1,node2,getDist(ps[node1],ps[node2])));
      G[node2].push_back(Edge(node2,node1,getDist(ps[node1],ps[node2])));
    }

    cin >> p >> q;
    sp = getIndex[p], gp = getIndex[q];

    rep(i,V)sort(G[i].begin(),G[i].end(),cmp);


    /*
    cout << "------------" << endl;
    rep(i,V){
      cout << i << " node---" << endl;
      rep(j,G[i].size()){
	cout << "(" << G[i][j].from << "," << G[i][j].to << "," << G[i][j].dist << ") ";
      }
      cout << endl;
    }
    cout << "goto Compute" << endl << endl;
    */
    compute();

  }
  return 0;
}