#include <bits/stdc++.h>
using namespace std;
long long f[10005][5], ans;
int vis[1000005];
int n, x;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  scanf("%d%d", &n, &x);
  f[1][1] = 1;
  f[1][2] = 2;
  f[1][3] = 3;
  f[1][4] = 5;
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= 4; j++) {
      f[i][j] = f[i - 1][j] + 6;
    }
  }
  printf("%lld\n", f[n][4] * x);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 4; j++) {
      printf("%lld ", f[i][j] * x);
    }
    puts("");
  }
  return 0;
}
