#include <bits/stdc++.h>
using namespace std;
vector<int> graph[10];
int main() {
  int N, Q;
  int a, b;
  cin >> N >> Q;
  for (int i = 0; i < N - 1; i++) {
    cin >> a >> b;
    graph[a].push_back(b);
  }
  for (int i = 0; i < 10; i++) {
    cout << i + 1 << "の根は";
    for (auto p : graph[i + 1]) cout << p << " ";
    cout << endl;
  }
}
