{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eBecause of the huge population of China, public transportation is very important. Bus is an important transportation method in traditional public transportation system. And it’s still playing an important role even now.\u003cbr\u003eThe bus system of City X is quite strange. Unlike other city’s system, the cost of ticket is calculated based on the distance between the two stations. Here is a list which describes the relationship between the distance and the cost.\u003cbr\u003e\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/0e82a72235091aeb4b817823246cb7f7?v\u003d1714382852\"\u003e\u003c/center\u003e\u003cbr\u003e\u003cbr\u003eYour neighbor is a person who is a really miser. He asked you to help him to calculate the minimum cost between the two stations he listed. Can you solve this problem for him?\u003cbr\u003eTo simplify this problem, you can assume that all the stations are located on a straight line. We use x-coordinates to describe the stations’ positions.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input consists of several test cases. There is a single number above all, the number of cases. There are no more than 20 cases.\u003cbr\u003eEach case contains eight integers on the first line, which are L1, L2, L3, L4, C1, C2, C3, C4, each number is non-negative and not larger than 1,000,000,000. You can also assume that L1\u0026lt;\u003dL2\u0026lt;\u003dL3\u0026lt;\u003dL4.\u003cbr\u003eTwo integers, n and m, are given next, representing the number of the stations and questions. Each of the next n lines contains one integer, representing the x-coordinate of the ith station. Each of the next m lines contains two integers, representing the start point and the destination.\u003cbr\u003eIn all of the questions, the start point will be different from the destination.\u003cbr\u003eFor each case,2\u0026lt;\u003dN\u0026lt;\u003d100,0\u0026lt;\u003dM\u0026lt;\u003d500, each x-coordinate is between -1,000,000,000 and 1,000,000,000, and no two x-coordinates will have the same value.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each question, if the two stations are attainable, print the minimum cost between them. Otherwise, print “Station X and station Y are not attainable.” Use the format in the sample.\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n1 2 3 4 1 3 5 7\r\n4 2\r\n1\r\n2\r\n3\r\n4\r\n1 4\r\n4 1\r\n1 2 3 4 1 3 5 7\r\n4 1\r\n1\r\n2\r\n3\r\n10\r\n1 4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1:\r\nThe minimum cost between station 1 and station 4 is 3.\r\nThe minimum cost between station 4 and station 1 is 3.\r\nCase 2:\r\nStation 1 and station 4 are not attainable.\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}