407108: GYM102697 079 Over The Rainbow

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

079. Over The Rainbowtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

A color wheel is a tool used to determine the relationships of different colors, often by the distance between two colors on the wheel.

Using the given simple color wheel above, your task is to determine the shortest numerical distance between two colors.

Input

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)

Output

Return the int value of the distance between the two colors, including the last color, but excluding the first.

ExampleInput
3
green red
purple orange
blue blue-green
Output
3
2
1
Note

(All inputs will be in lowercase)

加入题单

上一题 下一题 算法标签: