#ifdef DEBUG
#  define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include "testlib.h"
#define ff first
#define ss second
#define szof(x) ((int)x.size())
#ifndef LOCAL
#  define cerr __get_ce
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned long long ull;

using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;

int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;

int main(int argc, char* argv[]) {
  registerGen(argc, argv, 1);

  int t = opt<int>("t");
  int minn = opt<int>("minn");
  int maxn = opt<int>("maxn");

  auto ns = rnd.partition(t, maxn, minn);
    
  cout << t << '\n';
  for (int q = 0; q < t; q++) {
    int n = ns[q];
    cout << n << '\n';
    int x = rnd.next(1, int(sqrt(n)));
    int y = (n + x - 1) / x;
    if (rnd.next(0, 1) == 0) {
      swap(x, y);
    }
    vector<string> sx(x);
    for (int i = 0; i < x; i++) {
      for (int j = 0; j < 10; j++) {
        sx[i] += char('a' + rnd.next(0, 25));
      }
    }
    vector<string> sy(y);
    for (int i = 0; i < y; i++) {
      for (int j = 0; j < 10; j++) {
        sy[i] += char('a' + rnd.next(0, 25));
      }
    }
    int fail = -1;
    if (rnd.next(0, 1) == 0) {
      fail = rnd.next(1, n - 1);
    }
    vector<int> in_row(x, y);
    vector<int> in_col(y, x);
    in_row[0] -= 1;
    in_col[0] -= 1;
    vector<vector<bool>> used(x, vector<bool>(y, false));
    used[0][0] = true;
    cout << sx[0] << " " << sy[0] << '\n';
    int ci = 0, cj = 0;
    for (int it = 1; it < n; it++) {
      int ni, nj;
      if ((in_row[ci] == 0 && in_col[cj] == 0) || fail == it) {
        while (true) {
          ni = rnd.next(0, x - 1);
          nj = rnd.next(0, y - 1);
          if (!used[ni][nj]) {
            break;
          }
        }
      } else {
        while (true) {
          int idx = rnd.next(x + y);
          if (idx < y) {
            ni = ci;
            nj = idx;
          } else {
            ni = idx - y;
            nj = cj;
          }
          if (!used[ni][nj]) {
            break;
          }
        }
      }
      cout << sx[ni] << " " << sy[nj] << '\n';
      ci = ni;
      cj = nj;
      used[ni][nj] = true;
      in_row[ci] -= 1;
      in_col[cj] -= 1;
    }
  }

  return 0;
}