#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, k;
int a[N], b[N], c[N], d[N];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++)
    a[i] = k * (6 * i - 1), b[i] = k * (6 * i - 3), c[i] = k * (6 * i - 4),
    d[i] = k * (6 * i - 5);
  printf("%d\n", k * (6 * n - 1));
  for (int i = 1; i <= n; i++) printf("%d %d %d %d\n", a[i], b[i], c[i], d[i]);
}
