{"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\"\u003eThere is a path graph $G\u003d(V,E)$ with $n$ vertices. Vertices are numbered from $1$ to $n$ and there is an edge with unit length between $i$ and $i + 1$ $(1 \\le i \u0026lt; n)$. To make the graph more interesting, someone adds three more edges to the graph. The length of each new edge is $1$.\u003cbr\u003e\u003cbr\u003eYou are given the graph and several queries about the shortest path between some pairs of vertices.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"There are multiple test cases. The first line of input contains an integer $T$, indicating the number of test cases. For each test case:\u003cbr\u003e\u003cbr\u003eThe first line contains two integer $n$ and $m$ $(1 \\le n, m \\le 10^5)$ -- the number of vertices and the number of queries. The next line contains 6 integers $a_1, b_1, a_2, b_2, a_3, b_3$ $(1 \\le a_1,a_2,a_3,b_1,b_2,b_3 \\le n)$, separated by a space, denoting the new added three edges are $(a_1,b_1)$, $(a_2,b_2)$, $(a_3,b_3)$.\u003cbr\u003e\u003cbr\u003eIn the next $m$ lines, each contains two integers $s_i$ and $t_i$ $(1 \\le s_i, t_i \\le n)$, denoting a query.\u003cbr\u003e\u003cbr\u003eThe sum of values of $m$ in all test cases doesn\u0027t exceed $10^6$."}},{"title":"Output","value":{"format":"HTML","content":"For each test cases, output an integer $S\u003d(\\displaystyle\\sum_{i\u003d1}^{m} i \\cdot z_i) \\text{ mod } (10^9 + 7)$, where $z_i$ is the answer for $i$-th query."}},{"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\r\n10 2\r\n2 4 5 7 8 10\r\n1 5\r\n3 1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e7\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}