description: The Hat is a game of speedy explanation/guessing words (similar to Alias). It's fun. Try it! In this problem, we are talking about a variant of the game when the players are sitting at the table and everyone plays individually (i.e. not teams, but individual gamers play).
  
  n people gathered in a room with m tables (n ≥ 2m). They want to play the Hat k times. Thus, k games will be played at each table. Each player will play in k games.
  
  To do this, they are distributed among the tables for each game. During each game, one player plays at exactly one table. A player can play at different tables.
  
  Players want to have the most "fair" schedule of games. For this reason, they are looking for a schedule (table distribution for each game) such that:
  
    * At any table in each game there are either ⌊n/m⌋ people or ⌈n/m⌉ people (that is, either n/m rounded down, or n/m rounded up). Different numbers of people can play different games at the same table.
    * Let's calculate for each player the value b_i — the number of times the i-th player played at a table with ⌈n/m⌉ persons (n/m rounded up). Any two values of b_imust differ by no more than 1. In other words, for any two players i and j, it must be true |b_i - b_j| ≤ 1. 
  
  
  
  For example, if n=5, m=2 and k=2, then at the request of the first item either two players or three players should play at each table. Consider the following schedules:
  
    * First game: 1, 2, 3 are played at the first table, and 4, 5 at the second one. The second game: at the first table they play 5, 1, and at the second — 2, 3, 4. This schedule is not "fair" since b_2=2 (the second player played twice at a big table) and b_5=0 (the fifth player did not play at a big table).
    * First game: 1, 2, 3 are played at the first table, and 4, 5 at the second one. The second game: at the first table they play 4, 5, 2, and at the second one — 1, 3. This schedule is "fair": b=[1,2,1,1,1] (any two values of b_i differ by no more than 1). 
  
  
  
  Find any "fair" game schedule for n people if they play on the m tables of k games.
  
  Input
  
  The first line of the input contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases in the test.
  
  Each test case consists of one line that contains three integers n, m and k (2 ≤ n ≤ 2⋅10^5, 1 ≤ m ≤ ⌊n/2⌋, 1 ≤ k ≤ 10^5) — the number of people, tables and games, respectively.
  
  It is guaranteed that the sum of nk (n multiplied by k) over all test cases does not exceed 2⋅10^5.
  
  Output
  
  For each test case print a required schedule — a sequence of k blocks of m lines. Each block corresponds to one game, a line in a block corresponds to one table. In each line print the number of players at the table and the indices of the players (numbers from 1 to n) who should play at this table.
  
  If there are several required schedules, then output any of them. We can show that a valid solution always exists.
  
  You can output additional blank lines to separate responses to different sets of inputs.
  
  Example
  
  Input
  
  
  3
  5 2 2
  8 3 1
  2 1 3
  
  
  Output
  
  
  3 1 2 3
  2 4 5
  3 4 5 2
  2 1 3
  
  2 6 2
  3 3 5 1
  3 4 7 8
  
  2 2 1
  2 2 1
  2 2 1
solution: #include <bits/stdc++.h>
  using namespace std;
  using ll = long long;
  using vi = vector<int>;
  using vvi = vector<vi>;
  using vll = vector<ll>;
  using vvll = vector<vll>;
  using vb = vector<bool>;
  using vvb = vector<vb>;
  using vd = vector<double>;
  using vs = vector<string>;
  using pii = pair<int, int>;
  using pll = pair<ll, ll>;
  using pdd = pair<double, double>;
  using vpii = vector<pii>;
  using vpll = vector<pll>;
  using vpdd = vector<pdd>;
  template <typename T>
  void ckmin(T &a, const T &b) {
    a = min(a, b);
  }
  template <typename T>
  void ckmax(T &a, const T &b) {
    a = max(a, b);
  }
  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
  namespace __input {
  template <class T1, class T2>
  void re(pair<T1, T2> &p);
  template <class T>
  void re(vector<T> &a);
  template <class T, size_t SZ>
  void re(array<T, SZ> &a);
  template <class T>
  void re(T &x) {
    cin >> x;
  }
  void re(double &x) {
    string t;
    re(t);
    x = stod(t);
  }
  template <class Arg, class... Args>
  void re(Arg &first, Args &...rest) {
    re(first);
    re(rest...);
  }
  template <class T1, class T2>
  void re(pair<T1, T2> &p) {
    re(p.first, p.second);
  }
  template <class T>
  void re(vector<T> &a) {
    for (auto &x : a) re(x);
  }
  template <class T, size_t SZ>
  void re(array<T, SZ> &a) {
    for (auto &x : a) re(x);
  }
  }  // namespace __input
  using namespace __input;
  namespace __output {
  template <typename T>
  struct is_outputtable {
    template <typename C>
    static constexpr decltype(declval<ostream &>() << declval<const C &>(),
                              bool())
    test(int) {
      return true;
    }
    template <typename C>
    static constexpr bool test(...) {
      return false;
    }
    static constexpr bool value = test<T>(int());
  };
  template <
      class T, typename V = decltype(declval<const T &>().begin()),
      typename S = typename enable_if<!is_outputtable<T>::value, bool>::type>
  void pr(const T &x);
  template <class T,
            typename V = decltype(declval<ostream &>() << declval<const T &>())>
  void pr(const T &x) {
    cout << x;
  }
  template <class T1, class T2>
  void pr(const pair<T1, T2> &x);
  template <class Arg, class... Args>
  void pr(const Arg &first, const Args &...rest) {
    pr(first);
    pr(rest...);
  }
  template <class T, bool pretty = true>
  void prContain(const T &x) {
    if (pretty) pr("{");
    bool fst = 1;
    for (const auto &a : x) pr(!fst ? pretty ? ", " : " " : "", a), fst = 0;
    if (pretty) pr("}");
  }
  template <class T>
  void pc(const T &x) {
    prContain<T, false>(x);
    pr("\n");
  }
  template <class T1, class T2>
  void pr(const pair<T1, T2> &x) {
    pr("{", x.first, ", ", x.second, "}");
  }
  template <class T, typename V, typename S>
  void pr(const T &x) {
    prContain(x);
  }
  void ps() { pr("\n"); }
  template <class Arg>
  void ps(const Arg &first) {
    pr(first);
    ps();
  }
  template <class Arg, class... Args>
  void ps(const Arg &first, const Args &...rest) {
    pr(first, " ");
    ps(rest...);
  }
  }  // namespace __output
  using namespace __output;
  namespace __algorithm {
  template <typename T>
  void dedup(vector<T> &v) {
    sort((v).begin(), (v).end());
    v.erase(unique((v).begin(), (v).end()), v.end());
  }
  template <typename T>
  typename vector<T>::const_iterator find(const vector<T> &v, const T &x) {
    auto it = lower_bound((v).begin(), (v).end(), x);
    return it != v.end() && *it == x ? it : v.end();
  }
  template <typename T>
  size_t index(const vector<T> &v, const T &x) {
    auto it = find(v, x);
    assert(it != v.end() && *it == x);
    return it - v.begin();
  }
  template <typename I>
  struct _reversed_struct {
    I &v_;
    explicit _reversed_struct(I &v) : v_{v} {}
    typename I::reverse_iterator begin() const { return v_.rbegin(); }
    typename I::reverse_iterator end() const { return v_.rend(); }
  };
  template <typename I>
  _reversed_struct<I> reversed(I &v) {
    return _reversed_struct<I>(v);
  }
  template <typename I>
  struct _range_struct {
    const I first_, last_;
    explicit _range_struct(const I first, const I last)
        : first_{first}, last_{last} {}
    I begin() const { return first_; }
    I end() const { return last_; }
  };
  template <typename I>
  _range_struct<I> range(const I first, const I last) {
    return _range_struct<I>(first, last);
  }
  }  // namespace __algorithm
  using namespace __algorithm;
  namespace __io {
  void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(15);
  }
  }  // namespace __io
  using namespace __io;
  void solve() {
    int n, m, k;
    re(n, m, k);
    int start = 0;
    vector<int> b(n);
    for (int game = 0; game < k; game++) {
      ;
      vvi tables(m);
      int big = n / m + 1;
      int small = n / m;
      int big_count = n - small * m;
      int small_count = m - big_count;
      int table_index = 0;
      for (int i = 0; i < n; i++) {
        tables[table_index].push_back((start + i) % n);
        if (int((tables[table_index]).size()) ==
            ((table_index < big_count) ? big : small))
          table_index++;
      };
      start = (start + big * big_count) % n;
      for (auto &t : tables) {
        if (int((t).size()) != n / m)
          for (auto i : t) b[i]++;
        for (auto &i : t) i++;
        pr(int((t).size()), " ");
        pc(t);
      }
    };
    ps();
  }
  int main() {
    setIO();
    int T;
    re(T);
    for (int t = 0; t < T; t++) solve();
    return 0;
  }
  