// code by 樓影沫瞬_Hz17
#include <bits/stdc++.h>
using namespace std;#define getc() getchar_unlocked()
#define putc(a) putchar_unlocked(a)
#define en_ putc('\n')
#define e_ putc(' ')using pii = pair<int, int>;template<class T> inline void out(T n) {if(n < 0) putc('-'), n = -n;if(n > 9) out(n / 10);putc(n % 10 + '0');
}const int N = 5e5 + 10;
mt19937 rd(time(0));
vector<string> vec;inline int rdd(int l, int r) {return rd() % (r - l + 1) + l;
}inline string rdstr(size_t len) {string t; t.clear();for(size_t i = 1; i <= len; i ++) t += char(rdd(33, 126));return t;
}vector<int> e[N];inline void build_t(int n) {for(int i = 2; i <= n; i ++) {if(i >= 4000){int k = rdd(i - 4000, i - 1);e[i].push_back(k);e[k].push_back(i);continue;}int k = rdd(1, i - 1);e[i].push_back(k);e[k].push_back(i);}
}vector<string> chain;
vector<int> ch[N];inline vector<int> dfs(int u, int f) {vector<int> res;for(int v : e[u]) {if(v == f) continue;vector<int> t = dfs(v, u);for(int vv : t) {ch[vv].push_back(u);res.push_back(vv);}}if(e[u].size() == 1) {res.push_back(u);ch[u].push_back(u);}return res;
}signed main() {// 爱护你的电脑吧,小心些#ifndef ONLINE_JUDGEfreopen("i.ru", "w", stdout);#endifint n = 200000; // 节点int m = 1000; // 非树边数int L = 1000; // 非树边最大长度int q = 1000000; // 询问数int sz = 1, fu = 4; // 字符串长度 and 浮动(向上浮动)for(int i = 0; i <= n; i ++) vec.push_back(rdstr(sz + rd() % fu));build_t(n);dfs(1, 1);for(int i = 1; i <= m; i ++) {int len = rd() % L + 1;for(int j = 1; j <= len; j ++) {int no = rd() % n + 1;ch[i + n].push_back(no);}}int cnt = 0;random_shuffle(ch + 1, ch + m + n);for(int i = 1; i <= n + m; i ++) {if(ch[i].size()) cnt ++;}cout << cnt << '\n';for(int i = 1; i <= n + m; i ++) {if(ch[i].size()) {cout << ch[i].size() << ' ';for(int v : ch[i]) {cout << vec[v] << ' ';}en_;}}cout << vec[1] << '\n' << q << '\n';for(int i = 1; i <= q; i ++ ) {int r = rd() % n + 1;cout << vec[r] << '\n';}
}
// 星間~ 干渉~ 融解~ 輪迴~ 邂逅~ 再生~ ララバイ~
}
// 星間~ 干渉~ 融解~ 輪迴~ 邂逅~ 再生~ ララバイ~