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.awt.Point;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;

public class Main {

    public static void main(String[] args) throws IOException {
        //Scanner in = new Scanner(System.in);
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        StringBuilder sb = new StringBuilder();

        int n = in.nextInt();
        int k = in.nextInt();
        sb.append(((6 * n) - 1) * k).append("\n");
        for (int i = 0; i < n; i++) {
            sb.append((6 * i + 1) * k).append(" ").append((6 * i + 2) * k).append(" ").append((6 * i + 3) * k).append(" ").append((6 * i + 5) * k).append("\n");
        }
        out.println(sb.toString().trim());
        out.close();
    }

    static class Algorithm {

        static class ArithmeticProgression {

            static long Term(int n, int[] a, int m, long d) {
                return a[m] + (n - m) * d;
            }

            static long Term(int n, long[] a, int m, long d) {
                return a[m] + (n - m) * d;
            }
        }

        static HashSet<Integer> NumbersFrom(String digitsString) {
            int[] digits = new int[10];
            for (int i = digitsString.length() - 1; i >= 0; i--) {
                if (digitsString.charAt(i) >= '0' && digitsString.charAt(i) <= '9') {
                    digits[digitsString.charAt(i) - '0']++;
                }
            }
            return NumbersFrom(digits);
        }

        static HashSet<Integer> NumbersFrom(int[] digits) {
            int maxDigit = 0;
            for (int i = 0; i < digits.length; i++) {
                maxDigit += digits[i];
            }
            return NumbersFrom(digits, maxDigit);
        }

        static HashSet<Integer> NumbersFrom(int[] digits, int maxDigit) {
            ArrayList<Integer> list = new ArrayList<Integer>();
            for (int i = 0; i < digits.length; i++) {
                if (digits[i] > 0) {
                    list.add(i);
                }
            }
            int t1 = 0;
            int t2 = list.size();
            for (int i = 1; i < maxDigit; i++) {
                for (int j = t1; j < t2; j++) {
                    int number = list.get(j);
                    int temp = number;
                    while (temp > 0) {
                        digits[temp % 10]--;
                        temp /= 10;
                    }

                    for (int k = 0; k < 10; k++) {
                        if (digits[k] > 0) {
                            list.add(number * 10 + k);
                        }
                    }
                    while (number > 0) {
                        digits[number % 10]++;
                        number /= 10;
                    }
                }
                t1 = t2;
                t2 = list.size();
            }
            HashSet<Integer> set = new HashSet<Integer>(list);

            return set;
        }

        static long Exchange(long price, long[] array, boolean remainderAllowed) {
            return Exchange(price, array, true, remainderAllowed);
        }

        static long Exchange(long price, long[] array, boolean sorted, boolean remainderAllowed) {
            if (!sorted) {
                Arrays.sort(array);
            }
            long coins = 0;
            for (int i = array.length - 1; i >= 0 && price > 0; i--) {
                price -= array[i];
                coins++;
            }
            if (remainderAllowed) {
                if (price <= 0) {
                    return coins;
                } else {
                    return 0;
                }
            } else {
                if (price == 0) {
                    return coins;
                } else {
                    return 0;
                }
            }
        }

        static long Exchange(long price, int[] array, boolean remainderAllowed) {
            return Exchange(price, array, true, remainderAllowed);
        }

        static long Exchange(long price, int[] array, boolean sorted, boolean remainderAllowed) {
            if (!sorted) {
                Arrays.sort(array);
            }
            long coins = 0;
            for (int i = array.length - 1; i >= 0 && price > 0; i--) {
                price -= array[i];
                coins++;
            }
            if (remainderAllowed) {
                if (price <= 0) {
                    return coins;
                } else {
                    return 0;
                }
            } else {
                if (price == 0) {
                    return coins;
                } else {
                    return 0;
                }
            }
        }

        static long C(int n, int r) {
            if (r < n / 2) {
                return C(n, n - r);
            }
            return ZarbeMotevali(r + 1, n) / Fact(n - r);
        }

        private static long ZarbeMotevali(int first, int end) {
            long answer = 1;
            for (long i = first; i <= end; i++) {
                answer *= i;
            }
            return answer;
        }

        private static long Fact(int n) {
            return ZarbeMotevali(2, n);
        }

        static int GCD(int m, int n) {
            if (n > m) {
                return GCD(n, m);
            }
            if (m % n == 0) {
                return n;
            }
            return GCD(n, m % n);
        }

        static long GCD(long m, long n) {
            if (n > m) {
                return GCD(n, m);
            }
            if (m % n == 0) {
                return n;
            }
            return GCD(n, m % n);
        }

        static boolean IsPrime(long a) {
            if (a < 2) {
                return false;
            }
            if (a > 2 && a % 2 == 0) {
                return false;
            }
            long temp = (long) Math.sqrt(a);
            for (long i = 3; i <= temp; i += 2) {
                if (a % i == 0) {
                    return false;
                }
            }
            return true;
        }
    }
}

class Graph {

    private int[][] matrix;
    private boolean[] visited;
    private Stack<Integer> DFS;

    public Graph(int[][] matrix) {
        this.matrix = matrix;
        this.DFS = new Stack<Integer>();
        this.visited = new boolean[matrix.length];
    }

    public Stack<Integer> getDFS() {
        this.DFS(0);
        return DFS;
    }

    public Stack<Integer> getDFS(int vertex) {
        this.DFS.clear();
        this.DFS(vertex);
        return this.DFS;
    }

    private void DFS(int vertrx) {
        this.DFS.push(vertrx);
        this.visited[vertrx] = true;

        for (int i = 0; i < this.matrix[vertrx].length; i++) {
            if (this.matrix[vertrx][i] != 0 && !this.visited[i] && vertrx != i) {
                this.DFS(i);
            }
        }
    }
}

class FastScanner {

    private InputStream stream;
    private byte[] buffer = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream) {
        this.stream = stream;
    }

    int read() {
        if (numChars == -1) {
            throw new InputMismatchException();
        }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buffer);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0) {
                return -1;
            }
        }
        return buffer[curChar++];
    }

    boolean isWhiteSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    boolean isEndline(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    float nextFloat() {
        return Float.parseFloat(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String next() {
        int c = read();
        while (isWhiteSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isWhiteSpaceChar(c));
        return res.toString();
    }

    String nextLine() {
        int c = read();
        while (isEndline(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndline(c));
        return res.toString();
    }
}