#include <bits/stdc++.h>
using namespace std;
vector<int> Son[100100];
int Fa[100100], N, a[100100], b[100100];
void print(int x) {
  for (int i = 0; i < Son[x].size(); i++) {
    printf("%d %d\n", x, Son[x][i]);
    print(Son[x][i]);
  }
}
int main() {
  scanf("%d", &N);
  printf("%d\n", N - 1);
  for (int i = 1; i < N; i++) {
    scanf("%d%d", &a[i], &b[i]);
    printf("2 %d %d\n", a[i], b[i]);
    Fa[b[i]] = i;
  }
  for (int i = 1; i < N; i++) Son[Fa[a[i]]].push_back(i);
  for (int i = 0; i < Son[0].size(); i++) {
    if (i != Son[0].size() - 1) printf("%d %d\n", Son[0][i], Son[0][i + 1]);
    print(Son[0][i]);
  }
  return 0;
}
