{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eKreegan\u0027s attack in 1165 (Xeen\u0027s chronology) was one of the hardest challenges\r\nin the history of Enroth.\r\nHowever, the artifacts found after this war lead to the intense development\r\nof magic in Enroth.\r\nThe way some of these artifacts work is still unknown,\r\nand the best mages conduct serious research and experiments\r\ntrying to perceive their magic power.\u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eOne of these artifacts is a magic cube which, according to veterans\r\nof that war, was used by kreegans to prolong the spells\u0027 action,\r\nthus saving the power of mages.\r\nThis cube consists of many erudin crystals which are small cubes\r\nof equal size.\r\nSome faces of these crystals are covered with runes.\r\nAdjacent faces of two neighboring crystals contain the same rune on them.\r\nFaces that don\u0027t contain a rune on them form the faces of the whole\r\nassembled cube.\u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eUnfortunately, now this artifact is disassembled and is represented\r\nby the set of crystals.\r\nPrevious attempts to connect them were unsuccessful as the cube\r\nconstantly broke into pieces during the process.\r\nHowever, the scientists discovered that the relative positions of certain\r\npairs of crystals in the assembled cube play a great role in its magic power.\r\nNow the researchers want to analyze the runes on the faces of crystals\r\nto restore the way the cube should be assembled, and to calculate\r\nthe distance between some pairs of crystals in the assembled cube.\r\nCrystals can be rotated and moved arbitrarily.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe first line contains integers \u003ci\u003el\u003c/i\u003e and \u003ci\u003en\u003c/i\u003e which are the length of edge\r\nof a single crystal and the ratio of artifact edge\u0027s length to crystal\r\nedge\u0027s length (1 ≤ \u003ci\u003el\u003c/i\u003e ≤ 100; 2 ≤ \u003ci\u003en\u003c/i\u003e ≤ 30).\u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe following \u003ci\u003en\u003c/i\u003e\u003csup\u003e3\u003c/sup\u003e lines describe crystals.\r\nEach line contains six numbers in range from 0 to 10\u003csup\u003e9\u003c/sup\u003e\r\nwhich denote the numbers of runes on the faces of a crystal\r\naccording to the list of kreegan\u0027s runes by Patvin Darkenmore.\r\nNumber 0 means that the face doesn\u0027t have a rune on it.\r\nFaces are described in the following order:\r\nbottom, top, right, left, front, back.\r\nIt is guaranteed that any positive rune number\r\nis present exactly twice in the description of all crystals.\u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe next line contains an integer \u003ci\u003em\u003c/i\u003e which is the number of pairs of crystals\r\nresearchers want to investigate (1 ≤ \u003ci\u003em\u003c/i\u003e ≤ 10\u0026nbsp;000).\r\nEach of the following \u003ci\u003em\u003c/i\u003e lines contains integers \u003ci\u003ea\u003c/i\u003e and \u003ci\u003eb\u003c/i\u003e, which are\r\nthe numbers of crystals you should find a distance between\r\n\u003cnobr\u003e(1 ≤ \u003ci\u003ea\u003c/i\u003e \u0026lt; \u003ci\u003eb\u003c/i\u003e ≤ \u003ci\u003en\u003c/i\u003e\u003csup\u003e3\u003c/sup\u003e)\u003c/nobr\u003e.\r\nCrystals are numbered in the order they are described in input.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eFor each pair of crystals, output on a single line a distance between the\r\ncenters of these crystals in the assembled artifact.\r\nAbsolute or relative error should not exceed 10\u003csup\u003e−6\u003c/sup\u003e.\u003c/div\u003e\u003c/div\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\u003e1 2\r\n0 8 73 0 0 16\r\n0 9 0 73 0 1000\r\n0 146 4 0 16 0\r\n0 15 0 4 1000 0\r\n146 0 1 0 6 0\r\n15 0 0 1 2 0\r\n8 0 17 0 0 6\r\n9 0 0 17 0 2\r\n2\r\n1 5\r\n2 8\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1.4142135\r\n1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}