#include <bits/stdc++.h>
using namespace std;
int n, x, k;
int main() {
  scanf("%d%d", &n, &k);
  printf("%d\n", (n * 6 - 1) * k);
  for (int i = 1; i <= n; i++) {
    x = i * 6 - 5;
    printf("%d %d %d %d\n", x * k, (x + 1) * k, (x + 2) * k, (x + 4) * k);
  }
  return 0;
}
