#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 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;
  }
  for (int i = 0; i < n - k; i++) {
    if (i % 2 == 1) {
      int dx = 5;
      int dy = 12;
      if (rnd.next(2)) swap(dx, dy);
      if (rnd.next(2)) dx *= -1;
      if (rnd.next(2)) dy *= -1;
      x[i] = x[i - 1] + dx;
      y[i] = y[i - 1] + dy;
      r[i - 1] = rnd.next(1, 12);
      r[i] = 13 - r[i - 1];
    } else {
      x[i] = rnd.next(-max_x / 2, max_x / 2);
      y[i] = rnd.next(-max_x / 2, max_x / 2);
      r[i] = 1;
    }
  }
  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;
}