#include <iostream>
#include <vector>
#include <map>
using namespace std;

int timer = 0;
void dfs(int node, vector<vector<int>> &graph, vector<pair<int, int>> &time, map<pair<int, int>, string> &type){
    time[node].first = ++timer;

    for(int child: graph[node]){
        if(!time[child].first){
            type[{node, child}] = "Tree";
            dfs(child, graph, time, type);
        }

        else if(!time[child].second)
            type[{node, child}] = "Back";

        else if(time[node].first < time[child].first )
             type[{node, child}] = "Forward";

        else
             type[{node, child}] = "Cross";

    }

    time[node].second = ++timer;
}

using namespace std;

int main(){

    int nodes, egdes;
    cin >> nodes >> egdes;

    vector<vector<int>> graph(nodes+1);
    vector<pair<int, int>> time(nodes+1); // Arrival & Departure
    map<pair<int, int>, string> type;

    int from, to;
    while(egdes--){
        cin >> from >> to;
        graph[from].push_back(to);
    }

    // Show Graph
    cout << endl ;
    for(int node = 1; node <= nodes; node++){
        cout << node <<" : ";
        for(int child: graph[node])
            cout << child <<' ';
        cout << endl;
    }
    // dfs
    cout << endl;
    for(int node = 1; node <= nodes; node++)
        if(!time[node].first)
            dfs(node, graph, time, type);

    // Show Types
    cout << endl;
    for(auto node: type)
        cout << node.first.first <<" -> "<< node.first.second <<" is "<< node.second << endl;


    return 0;
}
