Problem: Dreamoon likes to play with sets, integers and <image>. <image> is defined as the largest positive integer that divides both a and b.

Let S be a set of exactly four distinct integers greater than 0. Define S to be of rank k if and only if for all pairs of distinct elements si, sj from S, <image>.

Given k and n, Dreamoon wants to make up n sets of rank k using integers from 1 to m such that no integer is used in two different sets (of course you can leave some integers without use). Calculate the minimum m that makes it possible and print one possible solution.

Input

The single line of the input contains two space separated integers n, k (1 ≤ n ≤ 10 000, 1 ≤ k ≤ 100).

Output

On the first line print a single integer — the minimal possible m. 

On each of the next n lines print four space separated integers representing the i-th set.

Neither the order of the sets nor the order of integers within a set is important. If there are multiple possible solutions with minimal m, print any one of them.

Examples

Input

1 1


Output

5
1 2 3 5


Input

2 2


Output

22
2 4 6 22
14 18 10 16

Note

For the first example it's easy to see that set {1, 2, 3, 4} isn't a valid set of rank 1 since <image>.

Solution (in JAVA):

Solution:
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;


public class main2 {
	
	static boolean cons(int[] vals, int num) {
		for (int i = 0; i < vals.length; i++) {
			if (vals[i] != 0) {
				if (vals[i] == num || gcd(vals[i], num) != 1) {
					return false;
				}
			}
		}
		
		return true;
	}
	
	static int gcd(int a, int b) {
		if (a < b) {
			return gcd(b, a);
		}
		
		while(b != 0) {
			int t = b;
			b = a % b;
			a = t;
		}
		
		return a;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		

		List<int[]> ans = new ArrayList<int[]>();
		ans.add(new int[] {1, 2, 3, 5});
		HashSet<Integer> used = new HashSet<Integer>();
		int first = 4;
		int nextOdd = 7;
		int max = 5;
		for (int i = 1; i < n; i++) {
			int[] next = new int[4];
			for (int j = 1; j < next.length; j++) {
				next[j] = nextOdd;
				nextOdd+=2;
			}
			
			for (int j = first; j < nextOdd; j+=2) {
				if (cons(next, j)) {
					next[0] = j;
					first = j + 2;
					break;
				}
			}
			
			for (int j = 0; j < next.length; j++) {
				max = Math.max(max, next[j]);
				used.add(next[j]);
			}
			
			ans.add(next);
		}
		
		System.out.println(max * k);
		for (int i = 0; i < ans.size(); i++) {
			System.out.println((ans.get(i)[0] * k) + " " + (ans.get(i)[1] * k) + " " + (ans.get(i)[2] * k) + " " + (ans.get(i)[3] * k));
		}
	}
	
	static List<Long> primes(int n) {
		List<Long> ans = new ArrayList<Long>();
		
		int[] numbers = new int[n + 1];
		for (int i = 0; i < numbers.length; i++) {
			numbers[i] = i;
		}
		
		numbers[0] = numbers[1] = -1;
		int current = 0;
		while(true) {
			
			boolean f = false;
			for (int i = current + 1; i < numbers.length; i++) {
				if(numbers[i] != -1) {
					current = i;
					f = true;
					break;
				}
			}
			
			if (!f) {
				break;
			}
			
			for (int i = current; i < numbers.length; i+=current) {
				numbers[i] = -1;
			}
			
			ans.add((long)current);
		}
		
		return ans;
	}
}