#include <bits/stdc++.h>
using namespace std;
const bool testing = false;
void program() {
  int n, k;
  scanf("%i%i", &n, &k);
  printf("%i\n", (6 * n - 1) * k);
  for (int i = 0; i < n; i++) {
    printf("%i %i %i %i\n", (6 * i + 1) * k, (6 * i + 2) * k, (6 * i + 3) * k,
           (6 * i + 5) * k);
  }
}
int main() {
  if (!testing) {
    program();
    return 0;
  }
  FILE* fin = NULL;
  fin = fopen("in.txt", "w+");
  fprintf(fin, "1 1\n");
  fclose(fin);
  freopen("in.txt", "r", stdin);
  printf("test case(1) => expected : \n");
  printf("5\n1 2 3 5\n");
  printf("test case(1) => founded  : \n");
  program();
  fin = fopen("in.txt", "w+");
  fprintf(fin, "2 2\n");
  fclose(fin);
  freopen("in.txt", "r", stdin);
  printf("test case(2) => expected : \n");
  printf("22\n2 4 6 22\n14 18 10 16\n");
  printf("test case(2) => founded  : \n");
  program();
  return 0;
}
