#include <bits/stdc++.h>
using namespace std;
const long long mod = (1e9) + 7;
int n, k;
long long dp[10010][4];
int main() {
  scanf("%d%d", &n, &k);
  dp[0][0] = 1;
  dp[0][1] = 2;
  dp[0][2] = 3;
  dp[0][3] = 5;
  long long ans;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 4; ++j) dp[i][j] = dp[i - 1][j] + 6;
  }
  ans = dp[n - 1][3] * k;
  printf("%I64d\n", ans);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 4; j++) {
      if (j) printf(" ");
      printf("%I64d", dp[i][j] * k);
    }
    printf("\n");
  }
  return 0;
}
