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:
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 1e8;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int, int> P;

P operator -(P p, P q){
  return P(p.first - q.first, p.second - q.second);
}

inline int distP(P p, P q){
  if(p.first == q.first) return abs(p.second - q.second);
  else return abs(p.first - q.first);
  //return abs(p.first - q.first) + abs(p.second - q.second);
}

inline int inner(P p, P q){
  return p.first * q.first + p.second * q.second;
}
inline int cross(P p, P q){
  return p.first * q.second - p.second * q.first;
}

inline bool ok(P p, P q){
  //assert(p.first == 0 || p.second == 0);
  //assert(q.first == 0 || q.second == 0);
  return (inner(p, q) > 0 && cross(p, q) == 0) || (inner(p, q) == 0 && cross(p, q) > 0);
}

int main(){
  assert(P(3, 1) - P(2, 10) == P(1, -9));
  assert(!ok(P(2, 0), P(0, -2)));
  assert(!ok(P(2, 0), P(-2, 0)));
  assert(ok(P(2, 0), P(2, 0)));
  assert(ok(P(2, 0), P(0, 2)));
  int M, N;
  while(cin>>M>>N && M){
    map<string, int> id_inter;
    vector<P> inter_p(M);
    REP(i, M){
      string inter; int x, y;
      cin>>inter>>x>>y;
      int t = i;
      //int t = id_inter.size();
      id_inter[inter] = t;
      inter_p[t] = P(x, y);
    }
    vector<int> connect[1000];
    REP(i, N){
      string inter1, inter2;
      cin>>inter1>>inter2;
      int id1 = id_inter[inter1];
      int id2 = id_inter[inter2];
      connect[id1].push_back(id2);
      connect[id2].push_back(id1);
    }
    string src, dst; cin>>src>>dst;
    int from = id_inter[src];
    int to = id_inter[dst];
    P dist[1000][1000];
    REP(i, M)REP(j, M) dist[i][j] = P(-1, -1);
    queue<P> que;
    FORIT(it, connect[from]){
      que.push(P(from, *it));
      dist[from][*it] = P(distP(inter_p[from], inter_p[*it]), 2);
    }
    P ans = P(INF, INF);
    while(!que.empty()){
      P p = que.front(); que.pop();
      P state = dist[p.first][p.second];
      if(p.second == to){
        ans = min(ans, state);
      }
      FORIT(it, connect[p.second]){
        P p1 = inter_p[p.second] - inter_p[p.first];
        P p2 = inter_p[*it] - inter_p[p.second];
        if(ok(p1, p2)){
          P next = P(state.first + distP(P(0, 0), p2), state.second + 1);
          if(dist[p.second][*it] != P(-1, -1) && dist[p.second][*it] <= next){
            continue;
          }
          dist[p.second][*it] = next;
          que.push(P(p.second, *it));
        }
      }
    }
    if(ans != P(INF, INF)) cout<<ans.second<<endl;
    else cout<<"impossible"<<endl;
    assert(id_inter.size() == M);
  }
  return 0;
}