#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  scanf("%d%d", &n, &k);
  printf("%d\n", k * (6 * (n - 1) + 5));
  for (int a = 0; a < n; ++a)
    printf("%d %d %d %d\n", k * (6 * a + 1), k * (6 * a + 2), k * (6 * a + 3),
           k * (6 * a + 5));
  return 0;
}
