#include #include #include #include #include #include #include #include using namespace std; const int MAXN = 1000; int father[MAXN], size[MAXN]; int find(int x) { return x == father[x] ? x : father[x] = find(father[x]); } int main() { int n; assert(scanf("%d", &n) == 1 && 1 <= n && n <= MAXN); priority_queue> heap; for (int i = 0; i < n; ++ i) { father[i] = i; size[i] = 1; heap.push(make_pair(-size[i], i)); } int answer = 0; while (heap.size()) { int sz = -heap.top().first; int u = heap.top().second; heap.pop(); if (size[find(u)] != sz || sz == n) { continue; } printf("1 %d %d\n", sz, n - sz); for (int i = 0; i < n; ++ i) { if (find(i) == find(u)) { printf("%d ", i + 1); } } puts(""); for (int i = 0; i < n; ++ i) { if (find(i) != find(u)) { printf("%d ", i + 1); } } puts(""); fflush(stdout); int a, b, c; assert(scanf("%d%d%d", &a, &b, &c) == 3); assert(1 <= a && a <= n); assert(1 <= b && b <= n); assert(1 <= c && c <= 100000); -- a; -- b; answer += c; int fa = find(a), fb = find(b); assert(fa != fb); father[fa] = fb; size[fb] += size[fa]; heap.push(make_pair(-size[fb], fb)); } printf("2 %d\n", answer); fflush(stdout); return 0; }