Comments

I used something like BFS to solve it in O((n+m)^2),and I think it should be E<F<D

thanks

I wrote an easier solution to problem E

#include <bits/stdc++.h>
#define int long long
using namespace std;

int n;
bool vis[200005];
vector<int> e[200005];
inline void dfs(int x) {
 vis[x] = true;
 for (auto i : e[x])
  if (!vis[i]) dfs(i);
 if (x != 1) cout << x << " ";
}

signed main() {
 cin >> n;
 for (int i = 1, c; i <= n; i++) {
  cin >> c;
  for (int j = 1, p; j <= c; j++) {
   cin >> p;
   e[i].push_back(p);
  }
 }
 dfs(1);
 return 0; 
} 

is that correct?