p213.ans1
======================
2
2 1 2
2 3 4

=================
p213.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;
}

=================
p213.in1
======================
4 4 1 4
1 2
1 3
2 4
3 4

=================
statement.txt
======================
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

=================
