#include <bits/stdc++.h>
int N, K;
int Sol[1010][5], v[5];
int gcd(int a, int b) {
  int r;
  while (b) b = (r = a % b, a = b, r);
  return a;
}
int main() {
  scanf("%d%d", &N, &K);
  printf("%d\n", (6 * N - 1) * K);
  for (int i = 0; i < N; ++i)
    printf("%d %d %d %d\n", (6 * i + 1) * K, (6 * i + 2) * K, (6 * i + 3) * K,
           (6 * i + 5) * K);
  return 0;
}
