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