#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long sum = 0, f = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar()) f |= (ch == '-');
  for (; isdigit(ch); ch = getchar()) sum = (sum << 1) + (sum << 3) + (ch ^ 48);
  return f ? -sum : sum;
}
void write(const long long x) {
  if (x < 0) {
    putchar('-');
    write(-x);
    return;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
int n, k, x;
int main() {
  n = read(), k = read();
  write((n * 6 - 1) * k), puts("");
  for (register long long i = (1); i <= (n); i++)
    x = i * 6 - 5, write(x * k), putchar(' '), write((x + 1) * k), putchar(' '),
    write((x + 2) * k), putchar(' '), write((x + 4) * k), puts("");
}
