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