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