#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
int n, k, q = 1, ans;
vector<int> v[N];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++, q += 6) {
    v[i].push_back(q);
    v[i].push_back(q + 2);
    v[i].push_back(q + 1);
    v[i].push_back(q + 4);
    ans = max(ans, q + 4);
  }
  printf("%d\n", ans * k);
  for (int i = 0; i < n; i++)
    printf("%d %d %d %d\n", k * v[i][0], k * v[i][1], k * v[i][2], k * v[i][3]);
}
