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