Roland loves growing flowers. He has recently grown a beautiful rose at point (0, 0) of the Cartesian coordinate system. The rose is so beautiful that Roland is afraid that the evil forces can try and steal it. 

To protect the rose, Roland wants to build n watch towers. Let's assume that a tower is a point on the plane at the distance of at most r from the rose. Besides, Roland assumes that the towers should be built at points with integer coordinates and the sum of squares of distances between all pairs of towers must be as large as possible. Note, that Roland may build several towers at the same point, also he may build some of them at point (0, 0).

Help Roland build the towers at the integer points so that the sum of squares of distances between all towers is maximum possible. Note that the distance in this problem is defined as the Euclidian distance between points.

Input

The first line contains two integers, n and r (2 ≤ n ≤ 8; 1 ≤ r ≤ 30).

Output

In the first line print an integer — the maximum possible sum of squared distances. In the i-th of the following n lines print two integers, xi, yi — the coordinates of the i-th tower. Each tower must be inside or on the border of the circle with radius r. Note that there may be several towers located at the same point of the plane, also some towers can be located at point (0, 0).

If there are multiple valid optimal arrangements, choose any of them.

Examples

Input

4 1


Output

16
0 1
0 1
0 -1
0 -1


Input

3 6


Output

312
0 6
5 -3
-5 -3
import java.io.*;
import java.util.*;
import java.math.BigInteger.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import static java.util.Arrays.*;
import java.util.logging.Level;
import java.util.logging.Logger;

// https://netbeans.org/kb/73/java/editor-codereference_ru.html#display
//<editor-fold defaultstate="collapsed" desc="Main">
public class Main {

    private void run() {
        Locale.setDefault(Locale.US);
        boolean oj = true;
        try {
            oj = System.getProperty("MYLOCAL") == null;
        } catch (Exception e) {
        }

        if (oj) {
            sc = new FastScanner(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
        } else {
            try {
                sc = new FastScanner(new FileReader("input.txt"));
                out = new PrintWriter(new FileWriter("output.txt"));
            } catch (IOException e) {
                MLE();
            }
        }
        Solver s = new Solver();
        s.sc = sc;
        s.out = out;
        s.solve();
        if (!oj) {
            err.println("Time: " + (System.currentTimeMillis() - timeBegin) / 1e3);
            err.printf("Mem: %d\n", (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) >> 20);
        }
        out.flush();
    }

    private void show(int[] arr) {
        for (int v : arr) {
            err.print(" " + v);
        }
        err.println();
    }

    public static void exit() {
        out.flush();
        out.close();
        System.exit(0);
    }

    public static void MLE() {
        int[][] arr = new int[1024 * 1024][];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = new int[1024 * 1024];
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }

    long timeBegin = System.currentTimeMillis();
    static FastScanner sc;
    static PrintWriter out;
    static PrintStream err = System.err;
}
//</editor-fold>

//<editor-fold defaultstate="collapsed" desc="FastScanner">
class FastScanner {

    BufferedReader br;
    StringTokenizer st;

    FastScanner(InputStreamReader reader) {
        br = new BufferedReader(reader);
        st = new StringTokenizer("");
    }

    String next() {
        while (!st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException ex) {
                Main.MLE();
            }
        }
        return st.nextToken();
    }

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

    long nextLong() {
        return Long.parseLong(next());
    }
}
//</editor-fold>

class Pt{
    int x, y;
    Pt(int x, int y) {
        this.x = x;
        this.y = y;
    }
    int distSq(){
        return x*x + y*y;
    }
    int distSq( Pt p ){
        return sq(p.x-x) + sq(p.y-y);
    }
    int sq( int x ){ return x*x; }
}

class Solver {

    FastScanner sc;
    PrintWriter out;
    PrintStream err = System.err;

    double f( int n ){ return n<=1? 1 : n * f(n-1); }
    
    double C( int m, int n ){ return f(n)/(f(m)*f(n-m)); }

    int n, r;
    TreeMap< Integer, ArrayList<Pt> > tm;
    ArrayList<Pt> _arr;
    Pt[] pt;
    int maxSum;
    Pt[] curPt, ansPt;

    void f( int pos, int ind, int sum ){
        if( pos == n ){
            if( maxSum < sum ){
                maxSum = sum;
                ansPt = curPt.clone();
            }
        }
        else{
            for (int i = ind; i < pt.length; i++) {
                curPt[pos] = pt[i];
                int curSum = 0;
                for( int j = 0; j < pos; ++j ){
                    curSum += curPt[j].distSq( curPt[pos] );
                }
                f( pos+1, i, sum + curSum );
            }
        }
    }
    
    void solve() {
        n = sc.nextInt();
        r = sc.nextInt();
        tm = new TreeMap<>();
        _arr = new ArrayList<>();
        for (int x = -r; x <= r; x++) {
        for (int y = -r; y <= r; y++) {
            Pt p = new Pt(x, y);
            if( p.distSq() <= r*r ){
                int d = p.distSq();
                if( !tm.containsKey(d) )
                    tm.put( d, new ArrayList<>());
                tm.get(d).add(p);
                _arr.add(p);
            }
        }
        }
        
        Collections.sort(_arr, (a,b) -> -(a.distSq() - b.distSq()) );
        
        for (Map.Entry<Integer, ArrayList<Pt>> e : tm.entrySet()) {
            err.println( e.getKey() +") "+ e.getValue().size() );
        }
        err.println(_arr.size());
        
        //for (int sz = 0; sz < 100; sz++) err.println(sz +") "+ C(8,sz));
        
        pt = Arrays.copyOf( _arr.toArray(new Pt[0]), min( 30, _arr.size() ) );
        
        curPt = new Pt[n];
        maxSum = -1;
        f( 0, 0, 0 );
        
        out.println( maxSum );
        for (Pt p : ansPt) out.println(p.x +" "+ p.y);
    }        
}
