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: import static java.lang.Math.*;
  
  import java.util.*;
  import java.io.*;
  
  public class Solution {
  
      public static void main(String[] args) {
          InputReader fs = new InputReader(System.in);
          PrintWriter pw = new PrintWriter(System.out);
          int t = fs.readInt();
          for (int tt = 0; tt < t; tt++) {
              int n = fs.readInt();
              int m = fs.readInt();
              int k = fs.readInt();
  
              int floor = n/m;
              int ceil = (n%m == 0)? floor: floor + 1;
              if (floor == ceil) {
                  for (int i = 0; i < k; i++) {
                      for (int j = 0; j < m; j++) {
                          pw.print(floor + " ");
                          for (int kk = j*floor + 1; kk <= (j+1)*floor; kk++) {
                              pw.print(kk + " ");
                          }
                          pw.println();
                      }
                  }
                  pw.println();
                  continue;
              }
  //            System.out.println("floor: " + floor);
  //            System.out.println("ceil: " + ceil);
              int last = 0;
              int rem = n%m;
              for (int i = 0; i < k; i++) {
                  for (int j = 0; j < rem; j++) {
                      pw.print(ceil + " ");
                      for (int kk = (j*ceil + 1 + last); kk <= ((j+1)*ceil + last); kk++) {
                          pw.print((kk%n == 0? n: kk%n) + " ");
                      }
                      pw.println();
                  }
                  for (int j = 0; j < m-rem; j++) {
                      pw.print(floor + " ");
  
                      for (int kk = (j*floor + (rem*ceil) + 1 + last); kk <= (j*floor + (rem*ceil) + floor + last); kk++) {
                          pw.print((kk%n == 0? n: kk%n) + " ");
                      }
                      pw.println();
                  }
                  last = (last + rem*ceil)%n;
              }
              pw.println();
          }
  
          pw.flush();
          pw.close();
      }
      static class InputReader
      {
          private InputStream stream;
          private byte[] buf = new byte[1024];
          private int curChar;
          private int numChars;
          private SpaceCharFilter filter;
  
          public InputReader(InputStream stream)
          {
              this.stream = stream;
          }
  
          public int read() {
              if (numChars == -1)
                  throw new InputMismatchException();
              if (curChar >= numChars)
              {
                  curChar = 0;
                  try
                  {
                      numChars = stream.read(buf);
                  }
                  catch (IOException e)
                  {
                      throw new InputMismatchException();
                  }
                  if (numChars <= 0)
                      return -1;
              }
              return buf[curChar++];
          }
  
          public int readInt() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              int sgn = 1;
              if (c == '-')
              {
                  sgn = -1;
                  c = read();
              }
              int res = 0;
              do
              {
                  if (c < '0' || c > '9')
                      throw new InputMismatchException();
                  res *= 10;
                  res += c - '0';
                  c = read();
              } while (!isSpaceChar(c));
              return res * sgn;
          }
  
          public String readString() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              StringBuilder res = new StringBuilder();
              do
              {
                  res.appendCodePoint(c);
                  c = read();
              } while (!isSpaceChar(c));
              return res.toString();
          }
  
          public double readDouble() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              int sgn = 1;
              if (c == '-')
              {
                  sgn = -1;
                  c = read();
              }
              double res = 0;
              while (!isSpaceChar(c) && c != '.')
              {
                  if (c == 'e' || c == 'E')
                      return res * Math.pow(10, readInt());
                  if (c < '0' || c > '9')
                      throw new InputMismatchException();
                  res *= 10;
                  res += c - '0';
                  c = read();
              }
              if (c == '.')
              {
                  c = read();
                  double m = 1;
                  while (!isSpaceChar(c))
                  {
                      if (c == 'e' || c == 'E')
                          return res * Math.pow(10, readInt());
                      if (c < '0' || c > '9')
                          throw new InputMismatchException();
                      m /= 10;
                      res += (c - '0') * m;
                      c = read();
                  }
              }
              return res * sgn;
          }
  
          public long readLong() {
              int c = read();
              while (isSpaceChar(c))
                  c = read();
              int sgn = 1;
              if (c == '-')
              {
                  sgn = -1;
                  c = read();
              }
              long res = 0;
              do
              {
                  if (c < '0' || c > '9')
                      throw new InputMismatchException();
                  res *= 10;
                  res += c - '0';
                  c = read();
              } while (!isSpaceChar(c));
              return res * sgn;
          }
  
          public boolean isSpaceChar(int c) {
              if (filter != null)
                  return filter.isSpaceChar(c);
              return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
          }
          public int[] readIntArray(int n) {
              int[] a = new int[n];
              for (int i = 0; i < n; i++) {
                  a[i] = readInt();
              }
              return a;
          }
          public int[] readIntArrayShifted(int n) {
              int[] a = new int[n + 1];
              for (int i = 0; i < n; i++) {
                  a[i + 1] = readInt();
              }
              return a;
          }
          public long[] readLongArray(int n) {
              long[] a = new long[n];
              for (int i = 0; i < n; i++) {
                  a[i] = readLong();
              }
              return a;
          }
          public String next() {
              return readString();
          }
  
          interface SpaceCharFilter {
              public boolean isSpaceChar(int ch);
          }
      }
  
  }