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