#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

int main() {
    int n, m;
    
    if (!(cin >> n >> m)) return 0;

    map<string, vector<string>> adjList;
    map<string, int> dist;
    map<string, string> parent;
    map<string, bool> visited; 

    for (int i = 0; i < m; i++) {
        string u, v;
        cin >> u >> v;

        if (u == v) {
            adjList[u]; 
        } else {
            adjList[u].push_back(v);
            adjList[v].push_back(u); 
        }
    }

    string tag, assemblyPoint;
    cin >> tag >> assemblyPoint; 
    adjList[assemblyPoint];      

    for (auto const& pair : adjList) {
        visited[pair.first] = false;
        dist[pair.first] = -1;
    }

    queue<string> q;
    dist[assemblyPoint] = 0;
    visited[assemblyPoint] = true;
    q.push(assemblyPoint);

    while (!q.empty()) {
        string current = q.front();
        q.pop();

        for (const string& neighbor : adjList[current]) {
            if (!visited[neighbor]) {
                visited[neighbor] = true;
                dist[neighbor] = dist[current] + 1;
                parent[neighbor] = current;
                q.push(neighbor);
            }
        }
    }

    for (auto const& pair : adjList) {
        string point = pair.first;

        if (point == assemblyPoint) continue; 

        if (!visited[point]) {
            cout << "Point: " << point << " Reachable: No Steps: - Route: No path exists\n";
        } else {
            cout << "Point: " << point << " Reachable: Yes Steps: " << dist[point] << " Route: ";
            
            string curr = point;
            while (curr != assemblyPoint) {
                cout << curr << " -> ";
                curr = parent[curr];
            }
            cout << assemblyPoint << "\n";
        }
    }

    return 0;
}