Problem: 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

Solution (in PYTHON):

Solution:
r=[[0]*31 for _ in range(9)]
r[2][1]='''4
-1 0
1 0
'''
r[3][1]='''8
-1 0
1 0
1 0
'''
r[4][1]='''16
-1 0
-1 0
1 0
1 0
'''
r[5][1]='''24
-1 0
-1 0
1 0
1 0
1 0
'''
r[6][1]='''36
-1 0
-1 0
-1 0
1 0
1 0
1 0
'''
r[7][1]='''48
-1 0
-1 0
-1 0
1 0
1 0
1 0
1 0
'''
r[8][1]='''64
-1 0
-1 0
-1 0
-1 0
1 0
1 0
1 0
1 0
'''
r[2][2]='''16
-2 0
2 0
'''
r[3][2]='''32
-2 0
2 0
2 0
'''
r[4][2]='''64
-2 0
-2 0
2 0
2 0
'''
r[5][2]='''96
-2 0
-2 0
2 0
2 0
2 0
'''
r[6][2]='''144
-2 0
-2 0
-2 0
2 0
2 0
2 0
'''
r[7][2]='''192
-2 0
-2 0
-2 0
2 0
2 0
2 0
2 0
'''
r[8][2]='''256
-2 0
-2 0
-2 0
-2 0
2 0
2 0
2 0
2 0
'''
r[2][3]='''36
-3 0
3 0
'''
r[3][3]='''76
-2 -2
0 3
3 0
'''
r[4][3]='''144
-3 0
-3 0
3 0
3 0
'''
r[5][3]='''218
-3 0
-2 -2
0 3
3 0
3 0
'''
r[6][3]='''324
-3 0
-3 0
-3 0
3 0
3 0
3 0
'''
r[7][3]='''432
-3 0
-3 0
-3 0
3 0
3 0
3 0
3 0
'''
r[8][3]='''576
-3 0
-3 0
-3 0
-3 0
3 0
3 0
3 0
3 0
'''
r[2][4]='''64
-4 0
4 0
'''
r[3][4]='''130
-2 -3
0 4
4 0
'''
r[4][4]='''256
-4 0
-4 0
4 0
4 0
'''
r[5][4]='''384
-4 0
-4 0
4 0
4 0
4 0
'''
r[6][4]='''576
-4 0
-4 0
-4 0
4 0
4 0
4 0
'''
r[7][4]='''768
-4 0
-4 0
-4 0
4 0
4 0
4 0
4 0
'''
r[8][4]='''1024
-4 0
-4 0
-4 0
-4 0
4 0
4 0
4 0
4 0
'''
r[2][5]='''100
-5 0
5 0
'''
r[3][5]='''224
-5 0
3 -4
3 4
'''
r[4][5]='''400
-5 0
-5 0
5 0
5 0
'''
r[5][5]='''624
-5 0
-5 0
3 -4
3 4
5 0
'''
r[6][5]='''900
-5 0
-5 0
-5 0
5 0
5 0
5 0
'''
r[7][5]='''1224
-5 0
-5 0
-5 0
3 -4
3 4
5 0
5 0
'''
r[8][5]='''1600
-5 0
-5 0
-5 0
-5 0
5 0
5 0
5 0
5 0
'''
r[2][6]='''144
-6 0
6 0
'''
r[3][6]='''312
-6 0
3 -5
3 5
'''
r[4][6]='''576
-6 0
-6 0
6 0
6 0
'''
r[5][6]='''880
-6 0
-3 -5
0 6
6 0
6 0
'''
r[6][6]='''1296
-6 0
-6 0
-6 0
6 0
6 0
6 0
'''
r[7][6]='''1740
-6 0
-6 0
-3 -5
0 6
6 0
6 0
6 0
'''
r[8][6]='''2304
-6 0
-6 0
-6 0
-6 0
6 0
6 0
6 0
6 0
'''
r[2][7]='''196
-7 0
7 0
'''
r[3][7]='''416
-3 -6
-3 6
7 0
'''
r[4][7]='''784
-7 0
-7 0
7 0
7 0
'''
r[5][7]='''1188
-7 0
-3 -6
0 7
7 0
7 0
'''
r[6][7]='''1764
-7 0
-7 0
-7 0
7 0
7 0
7 0
'''
r[7][7]='''2356
-7 0
-7 0
-3 -6
0 7
7 0
7 0
7 0
'''
r[8][7]='''3136
-7 0
-7 0
-7 0
-7 0
7 0
7 0
7 0
7 0
'''
r[2][8]='''256
-8 0
8 0
'''
r[3][8]='''554
-5 -6
0 8
8 0
'''
r[4][8]='''1024
-8 0
-8 0
8 0
8 0
'''
r[5][8]='''1572
-8 0
-5 -6
0 8
8 0
8 0
'''
r[6][8]='''2304
-8 0
-8 0
-8 0
8 0
8 0
8 0
'''
r[7][8]='''3102
-8 0
-8 0
-5 -6
0 8
8 0
8 0
8 0
'''
r[8][8]='''4096
-8 0
-8 0
-8 0
-8 0
8 0
8 0
8 0
8 0
'''
r[2][9]='''324
-9 0
9 0
'''
r[3][9]='''722
-4 -8
-4 8
9 0
'''
r[4][9]='''1296
-9 0
-9 0
9 0
9 0
'''
r[5][9]='''2014
-9 0
-4 -8
-4 8
9 0
9 0
'''
r[6][9]='''2916
-9 0
-9 0
-9 0
9 0
9 0
9 0
'''
r[7][9]='''3954
-9 0
-9 0
-4 -8
-4 8
9 0
9 0
9 0
'''
r[8][9]='''5184
-9 0
-9 0
-9 0
-9 0
9 0
9 0
9 0
9 0
'''
r[2][10]='''400
-10 0
10 0
'''
r[3][10]='''896
-10 0
6 -8
6 8
'''
r[4][10]='''1600
-10 0
-10 0
10 0
10 0
'''
r[5][10]='''2496
-10 0
-10 0
6 -8
6 8
10 0
'''
r[6][10]='''3600
-10 0
-10 0
-10 0
10 0
10 0
10 0
'''
r[7][10]='''4896
-10 0
-10 0
-10 0
6 -8
6 8
10 0
10 0
'''
r[8][10]='''6400
-10 0
-10 0
-10 0
-10 0
10 0
10 0
10 0
10 0
'''
r[2][11]='''484
-11 0
11 0
'''
r[3][11]='''1064
-11 0
6 -9
6 9
'''
r[4][11]='''1936
-11 0
-11 0
11 0
11 0
'''
r[5][11]='''2984
-11 0
-11 0
6 -9
6 9
11 0
'''
r[6][11]='''4356
-11 0
-11 0
-11 0
11 0
11 0
11 0
'''
r[7][11]='''5872
-11 0
-11 0
-6 -9
0 11
11 0
11 0
11 0
'''
r[8][11]='''7744
-11 0
-11 0
-11 0
-11 0
11 0
11 0
11 0
11 0
'''
r[2][12]='''576
-12 0
12 0
'''
r[3][12]='''1248
-12 0
6 -10
6 10
'''
r[4][12]='''2304
-12 0
-12 0
12 0
12 0
'''
r[5][12]='''3520
-12 0
-6 -10
0 12
12 0
12 0
'''
r[6][12]='''5184
-12 0
-12 0
-12 0
12 0
12 0
12 0
'''
r[7][12]='''6960
-12 0
-12 0
-6 -10
0 12
12 0
12 0
12 0
'''
r[8][12]='''9216
-12 0
-12 0
-12 0
-12 0
12 0
12 0
12 0
12 0
'''
r[2][13]='''676
-13 0
13 0
'''
r[3][13]='''1512
-5 -12
-5 12
13 0
'''
r[4][13]='''2704
-13 0
-13 0
13 0
13 0
'''
r[5][13]='''4224
-13 0
-5 -12
-5 12
12 -5
12 5
'''
r[6][13]='''6084
-13 0
-13 0
-13 0
13 0
13 0
13 0
'''
r[7][13]='''8280
-13 0
-13 0
-5 -12
-5 12
12 -5
12 5
13 0
'''
r[8][13]='''10816
-13 0
-13 0
-13 0
-13 0
13 0
13 0
13 0
13 0
'''
r[2][14]='''784
-14 0
14 0
'''
r[3][14]='''1746
-14 0
7 -12
7 12
'''
r[4][14]='''3136
-14 0
-14 0
14 0
14 0
'''
r[5][14]='''4870
-14 0
-7 -12
-5 13
14 0
14 0
'''
r[6][14]='''7056
-14 0
-14 0
-14 0
14 0
14 0
14 0
'''
r[7][14]='''9564
-14 0
-14 0
-7 -12
-5 13
14 0
14 0
14 0
'''
r[8][14]='''12544
-14 0
-14 0
-14 0
-14 0
14 0
14 0
14 0
14 0
'''
r[2][15]='''900
-15 0
15 0
'''
r[3][15]='''2016
-15 0
9 -12
9 12
'''
r[4][15]='''3600
-15 0
-15 0
15 0
15 0
'''
r[5][15]='''5616
-15 0
-15 0
9 -12
9 12
15 0
'''
r[6][15]='''8100
-15 0
-15 0
-15 0
15 0
15 0
15 0
'''
r[7][15]='''11016
-15 0
-15 0
-15 0
9 -12
9 12
15 0
15 0
'''
r[8][15]='''14400
-15 0
-15 0
-15 0
-15 0
15 0
15 0
15 0
15 0
'''
r[2][16]='''1024
-16 0
16 0
'''
r[3][16]='''2264
-16 0
9 -13
9 13
'''
r[4][16]='''4096
-16 0
-16 0
16 0
16 0
'''
r[5][16]='''6336
-16 0
-16 0
9 -13
9 13
16 0
'''
r[6][16]='''9216
-16 0
-16 0
-16 0
16 0
16 0
16 0
'''
r[7][16]='''12456
-16 0
-16 0
-16 0
9 -13
9 13
16 0
16 0
'''
r[8][16]='''16384
-16 0
-16 0
-16 0
-16 0
16 0
16 0
16 0
16 0
'''
r[2][17]='''1156
-17 0
17 0
'''
r[3][17]='''2600
-8 -15
-8 15
17 0
'''
r[4][17]='''4624
-17 0
-17 0
17 0
17 0
'''
r[5][17]='''7224
-17 0
-8 -15
-8 15
17 0
17 0
'''
r[6][17]='''10404
-17 0
-17 0
-17 0
17 0
17 0
17 0
'''
r[7][17]='''14160
-17 0
-17 0
-8 -15
-8 15
17 0
17 0
17 0
'''
r[8][17]='''18496
-17 0
-17 0
-17 0
-17 0
17 0
17 0
17 0
17 0
'''
r[2][18]='''1296
-18 0
18 0
'''
r[3][18]='''2888
-8 -16
-8 16
18 0
'''
r[4][18]='''5184
-18 0
-18 0
18 0
18 0
'''
r[5][18]='''8056
-18 0
-8 -16
-8 16
18 0
18 0
'''
r[6][18]='''11664
-18 0
-18 0
-18 0
18 0
18 0
18 0
'''
r[7][18]='''15816
-18 0
-18 0
-8 -16
-8 16
18 0
18 0
18 0
'''
r[8][18]='''20736
-18 0
-18 0
-18 0
-18 0
18 0
18 0
18 0
18 0
'''
r[2][19]='''1444
-19 0
19 0
'''
r[3][19]='''3218
-10 -16
-6 18
19 0
'''
r[4][19]='''5776
-19 0
-19 0
19 0
19 0
'''
r[5][19]='''9008
-18 -6
-18 -6
0 19
18 -6
19 0
'''
r[6][19]='''12996
-19 0
-19 0
-19 0
19 0
19 0
19 0
'''
r[7][19]='''17666
-19 0
-18 -6
-18 -6
0 19
18 -6
19 0
19 0
'''
r[8][19]='''23104
-19 0
-19 0
-19 0
-19 0
19 0
19 0
19 0
19 0
'''
r[2][20]='''1600
-20 0
20 0
'''
r[3][20]='''3584
-20 0
12 -16
12 16
'''
r[4][20]='''6400
-20 0
-20 0
20 0
20 0
'''
r[5][20]='''9984
-20 0
-20 0
12 -16
12 16
20 0
'''
r[6][20]='''14400
-20 0
-20 0
-20 0
20 0
20 0
20 0
'''
r[7][20]='''19584
-20 0
-20 0
-20 0
12 -16
12 16
20 0
20 0
'''
r[8][20]='''25600
-20 0
-20 0
-20 0
-20 0
20 0
20 0
20 0
20 0
'''
r[2][21]='''1764
-21 0
21 0
'''
r[3][21]='''3912
-17 -12
0 21
20 -6
'''
r[4][21]='''7056
-21 0
-21 0
21 0
21 0
'''
r[5][21]='''10942
-21 0
-17 -12
0 21
20 -6
21 0
'''
r[6][21]='''15876
-21 0
-21 0
-21 0
21 0
21 0
21 0
'''
r[7][21]='''21500
-21 0
-21 0
-17 -12
0 21
20 -6
21 0
21 0
'''
r[8][21]='''28224
-21 0
-21 0
-21 0
-21 0
21 0
21 0
21 0
21 0
'''
r[2][22]='''1936
-22 0
22 0
'''
r[3][22]='''4344
-22 0
11 -19
11 19
'''
r[4][22]='''7744
-22 0
-22 0
22 0
22 0
'''
r[5][22]='''12080
-22 0
-22 0
11 -19
11 19
22 0
'''
r[6][22]='''17424
-22 0
-22 0
-22 0
22 0
22 0
22 0
'''
r[7][22]='''23688
-22 0
-22 0
-22 0
11 -19
11 19
22 0
22 0
'''
r[8][22]='''30976
-22 0
-22 0
-22 0
-22 0
22 0
22 0
22 0
22 0
'''
r[2][23]='''2116
-23 0
23 0
'''
r[3][23]='''4712
-11 -20
-11 20
23 0
'''
r[4][23]='''8464
-23 0
-23 0
23 0
23 0
'''
r[5][23]='''13144
-23 0
-11 -20
-11 20
23 0
23 0
'''
r[6][23]='''19044
-23 0
-23 0
-23 0
23 0
23 0
23 0
'''
r[7][23]='''25808
-23 0
-23 0
-11 -20
-11 20
23 0
23 0
23 0
'''
r[8][23]='''33856
-23 0
-23 0
-23 0
-23 0
23 0
23 0
23 0
23 0
'''
r[2][24]='''2304
-24 0
24 0
'''
r[3][24]='''5138
-24 0
13 -20
13 20
'''
r[4][24]='''9216
-24 0
-24 0
24 0
24 0
'''
r[5][24]='''14326
-24 0
-24 0
13 -20
13 20
24 0
'''
r[6][24]='''20736
-24 0
-24 0
-24 0
24 0
24 0
24 0
'''
r[7][24]='''28122
-24 0
-24 0
-24 0
13 -20
13 20
24 0
24 0
'''
r[8][24]='''36864
-24 0
-24 0
-24 0
-24 0
24 0
24 0
24 0
24 0
'''
r[2][25]='''2500
-25 0
25 0
'''
r[3][25]='''5612
-24 -7
7 24
20 -15
'''
r[4][25]='''10000
-25 0
-25 0
25 0
25 0
'''
r[5][25]='''15624
-25 0
-7 -24
-7 24
20 -15
20 15
'''
r[6][25]='''22500
-25 0
-25 0
-25 0
25 0
25 0
25 0
'''
r[7][25]='''30624
-25 0
-25 0
-7 -24
-7 24
20 -15
20 15
25 0
'''
r[8][25]='''40000
-25 0
-25 0
-25 0
-25 0
25 0
25 0
25 0
25 0
'''
r[2][26]='''2704
-26 0
26 0
'''
r[3][26]='''6062
-12 -23
-12 23
26 0
'''
r[4][26]='''10816
-26 0
-26 0
26 0
26 0
'''
r[5][26]='''16896
-26 0
-10 -24
-10 24
24 -10
24 10
'''
r[6][26]='''24336
-26 0
-26 0
-26 0
26 0
26 0
26 0
'''
r[7][26]='''33120
-26 0
-26 0
-10 -24
-10 24
24 -10
24 10
26 0
'''
r[8][26]='''43264
-26 0
-26 0
-26 0
-26 0
26 0
26 0
26 0
26 0
'''
r[2][27]='''2916
-27 0
27 0
'''
r[3][27]='''6536
-27 0
14 -23
14 23
'''
r[4][27]='''11664
-27 0
-27 0
27 0
27 0
'''
r[5][27]='''18184
-27 0
-27 0
14 -23
14 23
27 0
'''
r[6][27]='''26244
-27 0
-27 0
-27 0
27 0
27 0
27 0
'''
r[7][27]='''35664
-27 0
-27 0
-27 0
14 -23
14 23
27 0
27 0
'''
r[8][27]='''46656
-27 0
-27 0
-27 0
-27 0
27 0
27 0
27 0
27 0
'''
r[2][28]='''3136
-28 0
28 0
'''
r[3][28]='''6984
-28 0
14 -24
14 24
'''
r[4][28]='''12544
-28 0
-28 0
28 0
28 0
'''
r[5][28]='''19488
-28 0
-22 -17
0 28
26 -10
28 0
'''
r[6][28]='''28224
-28 0
-28 0
-28 0
28 0
28 0
28 0
'''
r[7][28]='''38266
-28 0
-28 0
-22 -17
0 28
26 -10
28 0
28 0
'''
r[8][28]='''50176
-28 0
-28 0
-28 0
-28 0
28 0
28 0
28 0
28 0
'''
r[2][29]='''3364
-29 0
29 0
'''
r[3][29]='''7520
-20 -21
-7 28
28 -7
'''
r[4][29]='''13456
-29 0
-29 0
29 0
29 0
'''
r[5][29]='''20968
-29 0
-7 -28
0 29
20 -21
20 21
'''
r[6][29]='''30276
-29 0
-29 0
-29 0
29 0
29 0
29 0
'''
r[7][29]='''41200
-21 -20
-21 -20
-21 20
-21 20
29 0
29 0
29 0
'''
r[8][29]='''53824
-29 0
-29 0
-29 0
-29 0
29 0
29 0
29 0
29 0
'''
r[2][30]='''3600
-30 0
30 0
'''
r[3][30]='''8084
-24 18
0 -30
27 13
'''
r[4][30]='''14400
-30 0
-30 0
30 0
30 0
'''
r[5][30]='''22480
-30 0
-24 18
0 -30
27 13
30 0
'''
r[6][30]='''32400
-30 0
-30 0
-30 0
30 0
30 0
30 0
'''
r[7][30]='''44076
-30 0
-30 0
-30 0
18 24
24 -18
24 -18
27 13
'''
r[8][30]='''57600
-30 0
-30 0
-30 0
-30 0
30 0
30 0
30 0
30 0
'''
a,b=map(int,raw_input().split())
print r[a][b],