#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 flip = opt<int>("flip");

  vector<int> x(n), y(n), r(n);
  if (type == 1) {
    for (int i = 0; i < n; i++) {
      x[i] = 0;
      y[i] = 2 * i;
      r[i] = 1;
    }
  }
  if (type == 2) {
    int v = max_x / n;
    for (int i = 0; i < n; i++) {
      x[i] = 0;
      y[i] = -max_x + v * (2 * i + 1);
      r[i] = v;
    }
  }
  if (type == 3) {
    int v = max_x / (n / 2);
    for (int i = 0; i < n / 2; i++) {
      x[i] = x[i + n / 2] = 0;
      y[i] = v * (i + 1);
      y[i + n / 2] = -v * (i + 1);
      r[i] = r[i + n / 2] = y[i];
    }
  }
  if (type == 4) {
    double ratio = 1 + sqrt(2);
    int v = max_x / (n / 2);
    int p = int(sqrt(v / (ratio * ratio - 1)));
    int q = int(p * ratio);
    if (p % 2 == q % 2) {
      q -= 1;
    }
    while (__gcd(p, q) != 1) {
      p -= 1;
      q -= 1;
    }
    int dx = q * q - p * p;
    int dy = 2 * q * p;
    int rad = int(sqrt(dx * dx + dy * dy));
    x[0] = 0;
    y[0] = 0;
    r[0] = rad;
    for (int i = 1; i < n / 4; i++) {
      x[i] = dx * 2 * i;
      y[i] = dy * 2 * i;
      r[i] = rad;
      x[i + n / 4] = -dx * 2 * i;
      y[i + n / 4] = dy * 2 * i;
      r[i + n / 4] = rad;
      x[i + 2 * n / 4] = dx * 2 * i;
      y[i + 2 * n / 4] = -dy * 2 * i;
      r[i + 2 * n / 4] = rad;
      x[i + 3 * n / 4] = -dx * 2 * i;
      y[i + 3 * n / 4] = -dy * 2 * i;
      r[i + 3 * n / 4] = rad;
    }
    x[n / 4] = 0;
    y[n / 4] = 0;
    r[n / 4] = (max_x / rad / 2 * 2 - 1) * rad;
    x[2 * n / 4] = 0;
    y[2 * n / 4] = 0;
    r[2 * n / 4] = (max_x / 3 / rad / 2 * 2 - 1) * rad;
    x[3 * n / 4] = 0;
    y[3 * n / 4] = 0;
    r[3 * n / 4] = (max_x * 2 / 3 / rad / 2 * 2 - 1) * rad;
  }
  if (type >= 5 && type <= 11) {
    int par = -1;
    if (type == 11) {
      par = opt<int>("par");
    }
    int k = n / 2;
    double ratio = 1 + sqrt(2);
    int v = int(max_x / sqrt(2) / k);
    int p = int(sqrt(v / (ratio * ratio - 1)));
    int q = int(p * ratio);
    if (p % 2 == q % 2) {
      q -= 1;
    }
    while (__gcd(p, q) != 1) {
      p -= 1;
      q -= 1;
    }
    int dx = q * q - p * p;
    int dy = 2 * q * p;
    int rad = q * q + p * p;
    int ptr = 0;
    auto Dfs = [&](auto&& self, int i, int j) -> void {
      x[ptr] = -max_x + dx * (i + j);
      y[ptr] = -max_x + dy * (i + j);
      r[ptr] = rad * (j - i);
      ptr++;
      if (j - i == 1) {
        return;
      }
      int mid;
      if (type == 5) mid = (i + j) / 2;
      if (type == 6) mid = rnd.next(i + 1, j - 1);
      if (type == 7) mid = ((i + j) % 2 ? i + 1 : j - 1);
      if (type == 8) mid = (i + j == k ? (i + j) / 2 : (i + j < k ? i + 1 : j - 1));
      if (type == 9) mid = i + 1;
      if (type == 10) mid = j - 1;
      if (type == 11) {
        if (j - i > par) {
          mid = i + par;
        } else {
          if (j % (2 * par) == par) {
            mid = i + 1;
          } else {
            mid = j - 1;
          }
        }
      }
      self(self, i, mid);
      self(self, mid, j);
    };
    Dfs(Dfs, 0, k);
    n = ptr;
  }

  if (flip) {
    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;
}