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