#include <bits/stdc++.h>
using namespace std;
long long vis[100][100];
vector<long long> adj[20005];
vector<pair<long long, long long> > sh[20005];
vector<long long> viva[20005];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long m, n, k, l, i, cnt = 0, x, y, j;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
  }
  for (i = 0; i < n; i++) {
    sh[i].push_back({i, i});
    for (j = 0; j < n; j++) {
      viva[i].push_back(j * n + i);
    }
  }
  for (i = 0; i < n; i++) {
    for (auto &cv : adj[i]) {
      sh[i].push_back({i, viva[cv].back()});
      sh[cv].push_back({cv, viva[cv].back()});
      viva[cv].pop_back();
    }
  }
  for (i = 0; i < n; i++) {
    cout << sh[i].size() << endl;
    for (j = 0; j < sh[i].size(); j++) {
      assert(sh[i][j].first == i);
      cout << sh[i][j].first + 1 << ' ' << sh[i][j].second + 1 << endl;
    }
  }
  return 0;
}
