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