#include <bits/stdc++.h>
using namespace std;
long long toi(string s) {
  istringstream is(s);
  long long x;
  is >> x;
  return x;
}
int conversion(string p) {
  int num;
  num = atoi(p.c_str());
  return num;
}
string toString(int h) {
  stringstream ss;
  ss << h;
  return ss.str();
}
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return (a * (b / gcd(a, b))); }
bool cmp(pair<int, int> a, pair<int, int> b) { return a.first > b.first; }
void solve() {
  long long n, k;
  cin >> n >> k;
  cout << ((6 * n) - 1) * k << endl;
  for (int i = 0; i < n; i++) {
    cout << ((6 * i) + 1) * k << " " << ((6 * i) + 2) * k << " "
         << ((6 * i) + 3) * k << " " << ((6 * i) + 5) * k << endl;
  }
}
int main() {
  solve();
  return 0;
}
