<|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 vertices u with dist[u] < D. For each incident edge (u, v, id) with dist[v] == dist[u]+1, append id to answer[dist[u]]. (Each forward edge is recorded once, from its layer-i endpoint.)
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(N + M) to scan edges and group them. Fits N ≤ 400, M up to ~80 000.

4. C++ Implementation
```cpp
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

int n, m, s, t;
vector<vector<pair<int, int>>> adj;

void read() {
    cin >> n >> m >> s >> t;
    s--, t--;
    adj.assign(n, {});
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        adj[u].push_back({v, i});
        adj[v].push_back({u, i});
    }
}

void solve() {
    // We want the maximum number of pairwise edge-disjoint S-T cuts that
    // together cover every S-T path. The answer is the shortest-path distance
    // d = dist(S, T): for each level i in 0..d-1 the set of edges going from a
    // BFS layer i vertex to a layer i+1 vertex forms a valid S-T cut, and these
    // d cuts are edge-disjoint (an edge spans at most one consecutive layer
    // pair). No more than d disjoint cuts can exist because any shortest path
    // has exactly d edges and must be cut by each crystal type. So we BFS from
    // S, bucket every forward edge (dist[v] == dist[u] + 1) by dist[u], and
    // print one crystal type per layer.

    vector<int> dist(n, -1);

    queue<int> q;
    q.push(s);
    dist[s] = 0;

    while(!q.empty()) {
        int u = q.front();
        q.pop();
        for(auto [v, _]: adj[u]) {
            if(dist[v] == -1) {
                dist[v] = dist[u] + 1;
                q.push(v);
            }
        }
    }

    vector<vector<int>> answer(dist[t]);
    for(int u = 0; u < n; u++) {
        assert(dist[u] != -1);
        if(dist[u] >= dist[t]) {
            continue;
        }

        for(auto [v, id]: adj[u]) {
            if(dist[v] == dist[u] + 1) {
                answer[dist[u]].push_back(id + 1);
            }
        }
    }

    cout << dist[t] << '\n';
    for(int i = 0; i < dist[t]; i++) {
        cout << answer[i].size() << ' ' << answer[i] << '\n';
    }
}

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

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}
```

5. Python Implementation
```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.
