{"raw_statement":[{"iden":"statement","content":"A new computer scientist is trying to develop a new memory management system called \"spiral memory management\". \n\nThe basic idea of this system is that it represents the memory as a 2D grid with a predefined origin point, and the address of each memory location is represented as its (x,y) coordinates, and it tries to store frequently used data as close to the origin point as possible.\n\nThis system needs a search algorithm. Our computer scientist is currently developing an algorithm called \"square spiral search\".\n\nThe algorithm searches the memory locations in the following order (also shown in the figure):\n\n(0,0), (1,0), (1,1), (0,1), (-1,1), (-1,0), (-1,-1), (0,-1), (1,-1), (2,-1), (2,0), (2,1), (2,2), (1,2), (0,2), (-1,2), (-2,2), (-2,1), (-2,0), (-2,-1), (-2,-2,) ,(-1,-2) ... and so on.\n\nNow he is wondering: how many steps would it take to reach a memory location with the address (x, y) using the square spiral search. Can you help him find the answer? \n\nThe input starts with T the number of test cases, T test cases follows. \n\nEach test case consists of two numbers: X, Y the address of the memory location.\n\n - 1, 000, 000, 000 ≤ X ≤ 1, 000, 000, 000\n\n - 1, 000, 000, 000 ≤ Y ≤ 1, 000, 000, 000\n\nFor each test case print the number of steps it would take to reach the memory location ( x, y ) .\n\nThe number of steps to reach a memory location is defined as the number of memory locations searched before searching the requested location.\n\n"},{"iden":"input","content":"The input starts with T the number of test cases, T test cases follows. Each test case consists of two numbers: X, Y the address of the memory location. - 1, 000, 000, 000 ≤ X ≤ 1, 000, 000, 000 - 1, 000, 000, 000 ≤ Y ≤ 1, 000, 000, 000"},{"iden":"output","content":"For each test case print the number of steps it would take to reach the memory location ( x, y ) ."},{"iden":"examples","content":"Input31 01 1-2 1Output1217"},{"iden":"note","content":"The number of steps to reach a memory location is defined as the number of memory locations searched before searching the requested location."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ S $ be the sequence of grid points visited in square spiral order, starting at $ (0,0) $, with $ S_0 = (0,0) $, $ S_1 = (1,0) $, $ S_2 = (1,1) $, etc.  \n\nLet $ (x, y) \\in \\mathbb{Z}^2 $ be a target coordinate.  \n\n**Objective**  \nFor a given $ (x, y) $, find the smallest non-negative integer $ n $ such that $ S_n = (x, y) $.  \n\n**Constraints**  \n$ -10^9 \\leq x, y \\leq 10^9 $","simple_statement":"Given a point (x, y) on a 2D grid, find the step number when it is reached in a square spiral pattern starting from (0,0), moving right, up, left, down, and expanding outward in layers. The step count is the number of points visited before reaching (x, y).","has_page_source":false}