#include <bits/stdc++.h>
using namespace std;
struct box {
  int a, b, c, d;
  box(int a, int b, int c, int d) : a(a), b(b), c(c), d(d) {}
  friend ostream& operator<<(ostream& out, box bx) {
    out << bx.a << " " << bx.b << " " << bx.c << " " << bx.d << endl;
    return out;
  }
};
int main() {
  int n, k;
  cin >> n >> k;
  cout << (n * 6 - 1) * k << endl;
  for (int i = 0; i < n; ++i)
    cout << box((i * 6 + 1) * k, (i * 6 + 2) * k, (i * 6 + 3) * k,
                (i * 6 + 5) * k);
  return 0;
}
