#include <bits/stdc++.h>
using namespace std;
struct Node {
  long long a, b, c, d;
  Node(long long a = 0, long long b = 0, long long c = 0, long long d = 0)
      : a(a), b(b), c(c), d(d) {}
  void outpt(long long k) {
    printf("%I64d %I64d %I64d %I64d\n", a * k, b * k, c * k, d * k);
  }
};
vector<Node> ans;
int main() {
  long long n, k, m = 1;
  while (cin >> n >> k) {
    for (int i = 1; i <= n; i++) {
      ans.push_back(Node(m, m + 1, m + 2, m + 4));
      m += 6;
    }
    m -= 2;
    cout << m * k << endl;
    for (int i = 0; i < n; i++) ans[i].outpt(k);
  }
  return 0;
}
