#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T& num) {
  char CH;
  bool F = false;
  for (CH = getchar(); CH < '0' || CH > '9'; F = CH == '-', CH = getchar())
    ;
  for (num = 0; CH >= '0' && CH <= '9';
       num = num * 10 + CH - '0', CH = getchar())
    ;
  F && (num = -num);
}
int stk[70], tp;
template <class T>
inline void print(T p) {
  if (!p) {
    puts("0");
    return;
  }
  while (p) stk[++tp] = p % 10, p /= 10;
  while (tp) putchar(stk[tp--] + '0');
  putchar('\n');
}
const int mod = 1e9 + 7;
const double PI = acos(-1.0);
const int inf = 1e9;
const int N = 1e6 + 20;
const int maxn = 1e5 + 110;
const double eps = 1e-12;
int main() {
  int n, k;
  read(n);
  read(k);
  cout << (n - 1) * 6 * k + 5 * k << endl;
  for (int i = 1; i <= n; i++) {
    int t = (i - 1) * 6 + 1;
    printf("%d %d %d %d\n", t * k, t * k + k, t * k + 2 * k, t * k + 4 * k);
  }
  return 0;
}
