{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eRobots are becoming more and more popular. They are used nowadays not only in manufacturing plants,\u0026nbsp;but also at home. One programmer with his friends decided to create their own home robot. As you may\u0026nbsp;know most programmers like to drink beer when they gather together for a party. After the party there\u0026nbsp;are a lot of empty bottles left on the table. So, it was decided to program robot to collect empty bottles\u0026nbsp;from the table.\u003c/p\u003e\r\n\u003cp\u003eThe table is a rectangle with the length l and width w. Robot starts at the point (x\u003csub\u003er\u003c/sub\u003e, y\u003csub\u003er\u003c/sub\u003e) and n bottles\u0026nbsp;are located at points (x\u003csub\u003ei\u003c/sub\u003e, y\u003csub\u003ei\u003c/sub\u003e) for i \u003d 1, 2, ..., n. To collect a bottle robot must move to the point where\u0026nbsp;the bottle is located, take it, and then bring to some point on the border of the table to dispose it. Robot\u0026nbsp;can hold only one bottle at the moment and for simplicity of the control program it is allowed to release\u0026nbsp;bottle only at the border of the table.\u003c/p\u003e\r\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\r\n\u003cp style\u003d\"text-align: center;\"\u003e\u003cimg title\u003d\"Example\" src\u003d\"CDN_BASE_URL/274d50fcfff4005ec3ed34a94b77a10b?v\u003d1715836359\" alt\u003d\"Example\" width\u003d\"141\" height\u003d\"179\"\u003e\u003c/p\u003e\r\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003eYou can assume that sizes of robot and bottles are negligibly small (robot and bottles are points), so the\u0026nbsp;robot holding a bottle is allowed to move through the point where another bottle is located.\u0026nbsp;One of the subroutines of the robot control program is the route planning. You are to write the program\u0026nbsp;to determine the minimal length of robot route needed to collect all the bottles from the table.\u003c/p\u003e\r\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\u003cstrong\u003eInput\u003c/strong\u003e\u003c/p\u003e\r\n\u003cp\u003eThe first line of the input file contains T, the number of test cases. T test cases follow.\u003c/p\u003e\r\n\u003cp\u003eThe first line of each test case contains two integer numbers w and l — the width and the length of the\u0026nbsp;table (2 ≤ w, l ≤ 1000).\u003c/p\u003e\r\n\u003cp\u003eThe second line contains an integer number n — the number of bottles on the table\u0026nbsp;(1 ≤ n ≤ 18). Each of the following n lines contains two integer numbers x\u003csub\u003ei\u003c/sub\u003e and y\u003csub\u003ei\u003c/sub\u003e — coordinates\u0026nbsp;of the i-th bottle (0 \u0026lt; x\u003csub\u003ei\u003c/sub\u003e \u0026lt; w; 0 \u0026lt; y\u003csub\u003ei\u003c/sub\u003e \u0026lt; l). No two bottles are located at the same point.\u003c/p\u003e\r\n\u003cp\u003eThe last line of the test case contains two integer numbers x\u003csub\u003er\u003c/sub\u003e and y\u003csub\u003er\u003c/sub\u003e — coordinates of the robot’s initial\u0026nbsp;position (0 \u0026lt; x\u003csub\u003er\u003c/sub\u003e \u0026lt; w; 0 \u0026lt; y\u003csub\u003er\u003c/sub\u003e \u0026lt; l). Robot is not located at the same point with a bottle.\u003c/p\u003e\r\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\u003cstrong\u003eOutput\u003c/strong\u003e\u003c/p\u003e\r\n\u003cp\u003eFor each test case, output the length of the shortest route of the robot. Your answer should be accurate within an absolute\u0026nbsp;error of 10\u003csup\u003e-6\u003c/sup\u003e.\u003c/p\u003e\r\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\u003cstrong\u003eExample\u003c/strong\u003e\u003c/p\u003e\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\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\r\n3 4\r\n2\r\n1 1\r\n2 3\r\n2 1\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5.60555127546399\u003cspan style\u003d\"white-space: normal;\"\u003e\r\n\u003c/span\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e"}}]}