#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 main(int argc, char* argv[]) {
  registerGen(argc, argv, 1);

  int n = opt<int>("n");
  int max_x = opt<int>("max_x");
  int type = opt<int>("type");
  int w = opt<int>("w");
  int k = opt<int>("k");

  vector<int> x(n), y(n), r(n);
  for (int i = n - k; i < n; i++) {
    x[i] = 0;
    y[i] = 0;
    r[i] = max_x - i;
  }
  if (type == 1) {
    for (int i = 0; i < n - k; i++) {
      int row = i / w;
      int col = i % w;
      x[i] = 2 * row;
      y[i] = 2 * col;
      r[i] = 1;
    }
  }
  if (type == 2) {
    for (int i = 0; i < n - k; i++) {
      int row = i / w;
      int col = i % w;
      x[i] = 4 * row;
      if (row % 2 == 0) {
        y[i] = 6 * col;
        r[i] = 3;
      } else {
        y[i] = 6 * col + 3;
        r[i] = 2;
      }
    }
  }
  if (rnd.next(2)) {
    for (int i = 0; i < n; i++) {
      swap(x[i], y[i]);
    }
  }
  vector<int> order(n);
  iota(order.begin(), order.end(), 0);
  shuffle(order.begin(), order.end());
  cout << 1 << '\n';
  cout << n << '\n';
  for (int i = 0; i < n; i++) {
    cout << x[order[i]] << " " << y[order[i]] << " " << r[order[i]] << '\n';
  }

  return 0;
}