#include <bits/stdc++.h>
using namespace std;
void setIO(string a) {
  string in = a + ".in", out = a + ".out";
  freopen(in.c_str(), "r", stdin);
  freopen(out.c_str(), "w", stdout);
}
int n, k;
int main() {
  scanf("%d%d", &n, &k);
  int m = k * (6 * (n - 1) + 5);
  printf("%d\n", m);
  for (int i = (0); i <= (n - 1); i++) {
    printf("%d %d %d %d\n", k * (6 * i + 1), k * (6 * i + 2), k * (6 * i + 3),
           k * (6 * i + 5));
  }
  return 0;
}
