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