#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>
struct Vector;
struct Coordinate {
	int x{ 0 }, y{ 0 };
	Vector operator-(const Coordinate &that) const;
	double distance(const Coordinate& that) const;
};
struct Vector {
	int dx, dy;
	int cross(const Vector& that) const;
	double length() const;
};
namespace std {
	template <class T1, class T2>
	struct hash<std::pair<T1, T2>> {
		unsigned int operator() (const pair<T1, T2>& p) const {
			unsigned int lhs = hash<T1>()(p.first), rhs = hash<T2>()(p.second);
			return lhs ^ (rhs + 0x9e3779b9 + (lhs << 6) + (lhs >> 2));
		}
	};
}
int main() {
	while (true) {
		int m, n; std::cin >> m >> n; if (m == 0 && n == 0) break;
		std::unordered_map<std::string, Coordinate> cross;
		std::unordered_map<std::string, std::vector<std::string>> connection;
		for (auto i = 0; i < m; ++i) {
			std::string name; Coordinate coord;
			std::cin >> name >> coord.x >> coord.y;
			cross[name] = coord;
		}
		std::unordered_map<std::pair<std::string, std::string>, double> min_length;
		for (auto i = 0; i < n; ++i) {
			std::string p, q; std::cin >> p >> q;
			connection[p].push_back(q);
			connection[q].push_back(p);
			min_length[std::make_pair(p, q)] = DBL_MAX;
			min_length[std::make_pair(q, p)] = DBL_MAX;
		}
		std::string src, dst; std::cin >> src >> dst;
		std::unordered_map<std::pair<std::string, std::string>, int> min_pass;
		const auto comparator = [](const std::pair<std::pair<std::string, std::string>, double>& a, const std::pair<std::pair<std::string, std::string>, double>& b) {return a.second > b.second; };
		std::priority_queue<std::pair<std::pair<std::string, std::string>, double>, std::vector<std::pair<std::pair<std::string, std::string>, double>>, decltype(comparator)> queue(comparator);
		for (const auto& next : connection[src]) {
			const auto pair = std::make_pair(next, src);
			min_length[pair] = cross[src].distance(cross[next]);
			min_pass[pair] = 2;
			queue.emplace(pair, min_length[pair]);
		}
		while (!queue.empty()) {
			const auto top = queue.top(); queue.pop();
			if (min_length[top.first] < top.second) continue;
			const auto current_vec = cross[top.first.first] - cross[top.first.second];
			for (const auto& next : connection[top.first.first]) if (next != top.first.second) {
				const auto next_vec = cross[next] - cross[top.first.first];
				if (current_vec.cross(next_vec) >= 0) {
					const auto len = next_vec.length();
					const auto pair = std::make_pair(next, top.first.first);
					if (min_length[pair] > len + top.second + 1e-10) {
						min_length[pair] = len + top.second;
						min_pass[pair] = min_pass[top.first] + 1;
						queue.emplace(pair, len + top.second);
					}
					else if (min_length[pair] == len + top.second) {
						min_pass[pair] = std::min(min_pass[pair], min_pass[top.first] + 1);
					}
				}
			}
		}
		double len{ DBL_MAX };
		int pass{ INT_MAX };
		for (const auto& prev : connection[dst]) {
			const auto pair = std::make_pair(dst, prev);
			if (min_length[pair] == DBL_MAX) continue;
			if (len > min_length[pair]) {
				len = min_length[pair];
				pass = min_pass[pair];
			}
			else if (len == min_length[pair]) {
				pass = std::min(pass, min_pass[pair]);
			}
		}
		if (pass == INT_MAX) {
			std::cout << "impossible\n";
		}
		else {
			std::cout << pass << '\n';
		}
	}
}

Vector Coordinate::operator-(const Coordinate& that) const
{
	return Vector{ x - that.x, y - that.y };
}

double Coordinate::distance(const Coordinate& that) const
{
	return (*this - that).length();
}

int Vector::cross(const Vector& that) const
{
	return dx * that.dy - dy * that.dx;
}

double Vector::length() const
{
	return std::sqrt(dx * dx + dy * dy);
}



Measured memory_bytes: 4020