<|instruction|>
Solve the below problem. The solution should start with an abridged problem statement. Then key observations. Then full solution based on the observations. Then C++ and Python implementations with comments.

213. Strong Defence
time limit per test: 0.25 sec.
memory limit per test: 65536 KB
input: standard
output: standard



The Chief of the Galactic Empire has recently received some bad news from his spies. The Dark Lord is preparing to attack the Empire. His fleet of spaceships is ready for the first hyperjump.

It is well known that travelling in space is very simple. You just start from some star and make a series of hyperjumps to other stars. You can only jump from one star to another if they are connected with a special hyperjump tunnel, which is bidirectional, thus allowing to make a jump from one star that it connects to another. Of course, the tunnels are designed in such a way that there is the way to get from each star to any other one.

However, there is the way to block the hyperjump — to do this one must put a special battleship in the corresponding hypertunnel.

Of course, the Chief would like to block all hyperpaths from the star where the headquaters of the Dark Lord are located to the star where the capital of the Galactic Empire is. The resources of the Empire are almost unbounded, so it is easy to create as many battleships as needed. Unfortunately, there is one problem.

Each hyperjump blocking battleship must have a special crystal on board which allows him to stay in the hyperspace. There is a number of types of such crystals. The problem is that there is the way to destroy all battleships carrying some particular type of crystal.

Although it is known, that for each crystal type there is the way to destroy battleships powered by this crystal, there is hope that not all of those are known to Dark Lord engineers. So the Chief would like to use blocking ships in such a way that the following conditions are satisfied:

for each crystal type, if all ships with other crystal types are destroyed, battle ships with this crystal type block hypertunnels in such a way, that there is no path from Dark Lord's star to Empire Capital star;
the number of different crystal types used in ships is maximal possible;
no two ships block the same hypertunnel.

You may consider that there is the unlimited number of crystal types available and crystals of each type available.

Input

The first line of the input file contains N — the number of stars in the Galaxy(2 ≤ N ≤ 400), M -- the number of tunnels, S and T — numbers of stars where Dark Lord headquaters and Empire Capital are located respectively (S ≠ T).

Next M lines contain two integer numbers each — the numbers of the stars the corresponding tunnel connects. No tunnel connects a star to itself, no two stars are connected with more than one tunnel.


Output

First output L — the number of crystal types used. After that output L lines, for each crystal type output first Ki — the number of battleships with this crystal used, and then Ki numbers, identifying the hypertunnels blocked by the corresponding battleship. The tunnels are numbered starting from 1, as they are given in the input file.

Sample test(s)

Input
4 4 1 4
1 2
1 3
2 4
3 4

Output
2
2 1 2
2 3 4
Author:	Andrew Stankevich
Resource:	Petrozavodsk Summer Trainings 2003
Date:	2003-08-30

<|response|>
1. Abridged Problem Statement  
You are given an undirected connected graph with N vertices (stars) and M edges (tunnels), plus two special vertices S (source) and T (target). You want to choose some edges and color each chosen edge with exactly one of L “crystal types” so that:  
  • No edge has more than one color.  
  • For each crystal type c, if you remove all edges not colored c (i.e., keep only edges of color c), there is no path from S to T.  
Maximize L, and output one valid coloring (edge partition) achieving that maximum.

2. Key Observations  
  • Every simple path from S to T in an unweighted graph has length at least D, where D is the shortest‐path distance from S to T.  
  • In any S–T path of length D, there is exactly one edge that goes from BFS‐layer 0→1, exactly one edge from 1→2, …, and one from (D–1)→D.  
  • If you collect all edges that go from layer i to layer i+1 in the BFS tree, then removing those edges disconnects S from T (because every S–T path must use one such edge).  
  • All those layer‐i edges are disjoint from layer‐j edges when i≠j, so they form D disjoint cuts.  
  • You cannot do better than D cuts, because each cut must remove at least one distinct edge from every S–T path, and shortest S–T paths have length D.

Conclusion: The maximum number of crystal types L equals D (the BFS distance from S to T). The i‐th type consists of all edges that go from distance i to distance i+1.

3. Full Solution Approach  
Step 1. Read N, M, S, T and the list of edges (1-based indices). Build an adjacency list, storing for each edge its index.  
Step 2. Run a standard BFS from S to compute dist[v] = shortest‐path distance from S to v. Let D = dist[T].  
Step 3. Prepare an array of D lists, answer[0…D−1].  
Step 4. Iterate over all edges (u, v, id). If dist[u]+1 == dist[v], append id to answer[ dist[u] ]. Likewise if dist[v]+1 == dist[u], append id to answer[ dist[v] ].  
Step 5. Output D. Then for i = 0…D−1, output the size of answer[i] followed by the list of edge indices in answer[i].  

Complexity: O(N + M) for BFS plus O(M) to scan edges and group them. Fits N ≤ 400, M up to ~80 000.

4. C++ Implementation with Detailed Comments  
```cpp
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M, S, T;
    cin >> N >> M >> S >> T;
    // convert to 0-based
    --S; --T;

    // adjacency: for each u, list of (v, edge_id)
    vector<vector<pair<int,int>>> adj(N);
    vector<pair<int,int>> edges(M);  // store endpoints for later scan

    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        edges[i] = {u, v};
        adj[u].push_back({v, i});
        adj[v].push_back({u, i});
    }

    // BFS to compute dist[] from S
    const int INF = 1e9;
    vector<int> dist(N, INF);
    queue<int> q;
    dist[S] = 0;
    q.push(S);
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (auto &pr : adj[u]) {
            int v = pr.first;
            if (dist[v] == INF) {
                dist[v] = dist[u] + 1;
                q.push(v);
            }
        }
    }

    int D = dist[T];
    // D is the maximum number of crystal types
    // If T is unreachable, D would be INF, but problem guarantees connectivity.

    // Prepare D groups
    vector<vector<int>> answer(D);

    // Scan each edge once and assign it to the correct layer
    for (int i = 0; i < M; i++) {
        int u = edges[i].first;
        int v = edges[i].second;
        // check if u->v is forward in BFS layering
        if (dist[u] + 1 == dist[v]) {
            answer[dist[u]].push_back(i+1);  // store 1-based edge id
        }
        // or v->u is forward
        else if (dist[v] + 1 == dist[u]) {
            answer[dist[v]].push_back(i+1);
        }
    }

    // Output result
    cout << D << "\n";
    for (int i = 0; i < D; i++) {
        // each layer must have at least one edge (otherwise no S–T path of length D)
        cout << answer[i].size();
        for (int eid : answer[i]) {
            cout << " " << eid;
        }
        cout << "\n";
    }

    return 0;
}
```

5. Python Implementation with Detailed Comments  
```python
import sys
from collections import deque

def main():
    data = sys.stdin.read().split()
    it = iter(data)

    # Read input
    N = int(next(it))
    M = int(next(it))
    S = int(next(it)) - 1
    T = int(next(it)) - 1

    # Build adjacency list and store edges
    adj = [[] for _ in range(N)]
    edges = []
    for eid in range(M):
        u = int(next(it)) - 1
        v = int(next(it)) - 1
        edges.append((u, v))
        adj[u].append((v, eid))
        adj[v].append((u, eid))

    # BFS from S to compute dist[]
    INF = 10**9
    dist = [INF] * N
    dist[S] = 0
    dq = deque([S])
    while dq:
        u = dq.popleft()
        for v, _ in adj[u]:
            if dist[v] == INF:
                dist[v] = dist[u] + 1
                dq.append(v)

    D = dist[T]  # number of crystal types

    # Prepare D groups of edge IDs
    answer = [[] for _ in range(D)]

    # Assign each edge to the correct BFS‐level group
    for idx, (u, v) in enumerate(edges, start=1):
        if dist[u] + 1 == dist[v]:
            answer[dist[u]].append(idx)
        elif dist[v] + 1 == dist[u]:
            answer[dist[v]].append(idx)

    # Print output
    out = []
    out.append(str(D))
    for layer in range(D):
        lst = answer[layer]
        out.append(str(len(lst)) + " " + " ".join(map(str, lst)))
    sys.stdout.write("\n".join(out))

if __name__ == "__main__":
    main()
```

Explanation Summary:  
- Compute the shortest‐path distance D from S to T via BFS.  
- The maximum number of disjoint “cuts” that each independently separate S and T is exactly D.  
- Those cuts correspond to edges that cross each BFS level i→i+1, for i=0…D−1.  
- Collect and output those edge sets as your coloring groups.