#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;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

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");
  int minh = opt<int>("minh");
  int maxh = opt<int>("maxh");

  auto ns = rnd.partition(t, maxn, minn);
    
  cout << t << '\n';
  for (int q = 0; q < t; q++) {
    int n = ns[q];
    cout << n << '\n';
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
      p[i] = rnd.next(minh, maxh);
    }
    auto ps = p;
    sort(ps.begin(), ps.end());
    ps.resize(unique(ps.begin(), ps.end()) - ps.begin());
    int sz = int(ps.size());
    vector<int> d(sz);
    for (int i = 0; i < sz; i++) {
      int low = (i == 0 ? 0 : d[i - 1]);
      int high = (i == 0 ? ps[i] - 1 : ps[i] - (ps[i - 1] - d[i - 1]));
      d[i] = rnd.next(low, high);
    }
    if (rnd.next(2) && sz > 1) {
      int i = rnd.next(sz - 1);
      swap(d[i], d[i + 1]);
    }
    map<int, int> mp;
    for (int i = 0; i < sz; i++) {
      mp[ps[i]] = max(minh, min(maxh, ps[i] - d[i]));
    }
    for (int i = 0; i < n; i++) {
      cout << mp[p[i]] << " \n"[i == n - 1];
    }
    for (int i = 0; i < n; i++) {
      cout << p[i] << " \n"[i == n - 1];
    }
  }

  return 0;
}