#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2500;
int n, k;
inline long long Read() {
  long long x = 0, f = 0;
  char c = getchar();
  while (!isdigit(c)) {
    f |= c == '-';
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f ? -x : x;
}
inline void Write(const long long &x) {
  if (x < 0) {
    putchar('-');
    Write(-x);
    return;
  }
  if (x > 9) {
    Write(x / 10);
  }
  putchar((x % 10) ^ 48);
  return;
}
signed main() {
  n = Read(), k = Read();
  Write((6 * n - 1) * k), putchar('\n');
  for (register int i = 1, j = 1; i <= n; ++i, j += 6) {
    Write(j * k), putchar(' '), Write((j + 1) * k), putchar(' '),
        Write((j + 2) * k), putchar(' '), Write((j + 4) * k), putchar('\n');
  }
  return 0;
}
