{"raw_statement":[{"iden":"statement","content":"A color wheel is a tool used to determine the relationships of different colors, often by the distance between two colors on the wheel.\n\nUsing the given simple color wheel above, your task is to determine the shortest numerical distance between two colors.\n\nThe first line will contain an integer $n$, the number of test cases that will follow. The next lines will contain two strings in each individual line, which will be the two colors that will taken under measurement. (All colors will have the same name as the colors of the image above)\n\nReturn the int value of the distance between the two colors, including the last color, but excluding the first.\n\n(All inputs will be in lowercase)\n\n"},{"iden":"input","content":"The first line will contain an integer $n$, the number of test cases that will follow. The next lines will contain two strings in each individual line, which will be the two colors that will taken under measurement. (All colors will have the same name as the colors of the image above)"},{"iden":"output","content":"Return the int value of the distance between the two colors, including the last color, but excluding the first."},{"iden":"note","content":"(All inputs will be in lowercase)"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of test cases.  \nLet $ C = (c_1, c_2, \\dots, c_6) $ be the ordered cycle of colors:  \n$ c_1 = \\text{\"red\"} $, $ c_2 = \\text{\"yellow\"} $, $ c_3 = \\text{\"green\"} $, $ c_4 = \\text{\"cyan\"} $, $ c_5 = \\text{\"blue\"} $, $ c_6 = \\text{\"magenta\"} $.  \nLet $ T = \\{(x_k, y_k) \\mid k \\in \\{1, \\dots, n\\}\\} $ be the set of test cases, where $ x_k, y_k \\in C $.\n\n**Constraints**  \n1. $ 1 \\le n \\le \\text{some bound (implied by input)} $  \n2. For each $ k $, $ x_k, y_k \\in \\{c_1, \\dots, c_6\\} $\n\n**Objective**  \nFor each test case $ (x_k, y_k) $, compute the shortest clockwise distance from $ x_k $ to $ y_k $ along the cycle $ C $, defined as:  \nLet $ i = \\text{index of } x_k $, $ j = \\text{index of } y_k $ (1-based).  \nThen:  \n$$\nd_k = \\min\\left( (j - i) \\bmod 6,\\ (i - j) \\bmod 6 \\right)\n$$  \nBut since the problem specifies *\"including the last color, but excluding the first\"*, and implies **clockwise distance** (as per typical color wheel interpretation), we interpret it as:  \n$$\nd_k = (j - i) \\bmod 6\n$$  \nwith the understanding that if $ j < i $, we wrap around:  \n$$\nd_k = \\begin{cases}\nj - i & \\text{if } j \\ge i \\\\\nj - i + 6 & \\text{if } j < i\n\\end{cases}\n$$  \nEquivalently:  \n$$\nd_k = (j - i + 6) \\bmod 6\n$$  \nBut note: since we include the last and exclude the first, this is the number of steps from $ x_k $ to $ y_k $ clockwise, **not counting** the start but **counting** the end — i.e., the number of edges traversed.  \nThis matches $ (j - i) \\bmod 6 $, and since distances are non-negative and minimal in a 6-cycle, we use:  \n$$\n\\boxed{d_k = (j - i + 6) \\bmod 6}\n$$  \nHowever, if the problem means the **shortest** distance (not necessarily clockwise), then:  \n$$\nd_k = \\min\\left( (j - i + 6) \\bmod 6,\\ (i - j + 6) \\bmod 6 \\right)\n$$  \nBut the phrase *\"including the last color, but excluding the first\"* and *\"distance between two colors on the wheel\"* in context of a **color wheel** typically implies **clockwise** path.  \nMoreover, the example (if provided) would clarify — but since none is, and the problem says *\"shortest numerical distance\"*, we must assume **minimal circular distance**.\n\nThus, final objective:  \nFor each test case, let $ i, j \\in \\{1,2,3,4,5,6\\} $ be the 1-based indices of the two colors in $ C $.  \nCompute:  \n$$\nd_k = \\min\\left( |j - i|,\\ 6 - |j - i| \\right)\n$$","simple_statement":"Find the shortest distance between two colors on a color wheel, moving clockwise. Return the number of steps from the first color to the second, not including the first but including the second.","has_page_source":false}