Compute transitive closure via Floyd-Warshall

Given a directed graph, compute its positive-length reachability relation. For every ordered pair of vertices (u, v) connected by a directed path containing at least one edge, output u v on its own line. Output pairs in increasing source vertex order, then increasing destination order. A self-pair is included only when the vertex belongs to a directed cycle.

Examples
Input: "10 1\n1 1"
Output: "1 1"
Hints

Compute transitive closure via Floyd-Warshall

Given a directed graph, compute its positive-length reachability relation. For every ordered pair of vertices `(u, v)` connected by a directed path containing at least one edge, output `u v` on its own line. Output pairs in increasing source vertex order, then increasing destination order. A self-pair is included only when the vertex belongs to a directed cycle.