{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eThere is a connected graph with $$$n$$$ vertices and $$$m$$$ undirected edges.\u003c/p\u003e\u003cp\u003eYou are given $$$Q$$$ queries, each containing $$$4$$$ integers $$$u,v,x,y$$$. For each query, you need to find one path from $$$u$$$ to $$$x$$$ and another from $$$v$$$ to $$$y$$$, or one path from $$$u$$$ to $$$y$$$ and another from $$$v$$$ to $$$x$$$, so that the common edges between these two paths is the least.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains two integers $$$n,m\\ (2\\le n\\le 2\\cdot 10^5,1\\le m\\le 3\\cdot 10^5)$$$ as described above.\u003c/p\u003e\u003cp\u003eEach of the next $$$m$$$ lines contains two integers $$$u,v\\ (1\\le u,v\\le n)$$$, indicating an undirected edge between $$$u$$$ and $$$v$$$. It is guaranteed that there are no self-loops or multiple edges, and that the graph is connected.\u003c/p\u003e\u003cp\u003eThe $$$(m+2)$$$-th line contains an integer $$$Q\\ (1\\le Q\\le 10^5)$$$, the number of queries.\u003c/p\u003e\u003cp\u003eEach of the next $$$Q$$$ lines contains four integers $$$u,v,x,y\\ (1\\le u,v,x,y\\le n)$$$, the starting points and the end points of the two paths.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each query output an integer in a line, indicating the minimum number of common edges.\u003c/p\u003e"}},{"title":"Examples","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\u003e7 8\n1 2\n2 3\n3 1\n3 4\n4 5\n5 6\n6 7\n7 4\n4\n1 1 3 3\n1 2 5 6\n1 5 6 2\n4 5 6 7\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n1\n0\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","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\u003e8 7\n1 2\n2 3\n3 4\n3 5\n1 6\n6 7\n6 8\n3\n4 5 7 8\n4 3 2 1\n5 5 8 8\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\n1\n5\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first example, you can select path $$$(1,2)-(2,3)$$$ and $$$(1,3)$$$ for the first query so that there are no common edges. But in the second query, both paths will pass through $$$(3,4)$$$ so there is at least one common edge.\u003c/p\u003e"}}]}