{"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\"\u003eCity C is really a nightmare of all drivers for its traffic jams. To solve the traffic problem, the mayor plans to build a RTQS (Real Time Query System) to monitor all traffic situations. City C is made up of N crossings and M roads, and each road connects two crossings. All roads are bidirectional. One of the important tasks of RTQS is to answer some queries about route-choice problem. Specifically, the task is to find the crossings which a driver MUST pass when he is driving from one given road to another given road.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"There are multiple test cases.\u003cbr\u003eFor each test case:\u003cbr\u003eThe first line contains two integers N and M, representing the number of the crossings and roads.\u003cbr\u003eThe next M lines describe the roads. In those M lines, the i\u003csup\u003eth\u003c/sup\u003e line (i starts from 1)contains two integers X\u003csub\u003ei\u003c/sub\u003e and Y\u003csub\u003ei\u003c/sub\u003e, representing that road\u003csub\u003ei\u003c/sub\u003e connects crossing X\u003csub\u003ei\u003c/sub\u003e and Y\u003csub\u003ei\u003c/sub\u003e (X\u003csub\u003ei\u003c/sub\u003e≠Y\u003csub\u003ei\u003c/sub\u003e).\u003cbr\u003eThe following line contains a single integer Q, representing the number of RTQs.\u003cbr\u003eThen Q lines follows, each describing a RTQ by two integers S and T(S≠T) meaning that a driver is now driving on the roads and he wants to reach roadt . It will be always at least one way from roads to roadt.\u003cbr\u003eThe input ends with a line of “0 0”.\u003cbr\u003ePlease note that: 0\u0026lt;N\u0026lt;\u003d10000, 0\u0026lt;M\u0026lt;\u003d100000, 0\u0026lt;Q\u0026lt;\u003d10000, 0\u0026lt;X\u003csub\u003ei\u003c/sub\u003e,Y\u003csub\u003ei\u003c/sub\u003e\u0026lt;\u003dN, 0\u0026lt;S,T\u0026lt;\u003dM \u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each RTQ prints a line containing a single integer representing the number of crossings which the driver MUST pass."}},{"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\u003e5 6\r\n1 2\r\n1 3\r\n2 3\r\n3 4\r\n4 5\r\n3 5\r\n2\r\n2 3\r\n2 4\r\n0 0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\r\n1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}