{"trustable":false,"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":"MD","content":"Z"}},{"title":"Input","value":{"format":"MD","content":"The input consists of T test cases. The number of test cases ) (T is given in the first line of the input. Each test case begins with a line containing an integer N , 1\u0026lt;\u003dN\u0026lt;\u003d200 , that represents the number of tables to move. Each of the following N lines contains two positive integers s and t, representing that a table is to move from room number s to room number t (each room number appears at most once in the N lines). From the N+3-rd line, the remaining test cases are listed in the same manner as above. \n\u003cbr\u003e"}},{"title":"Output","value":{"format":"MD","content":"The output should contain the minimum time in minutes to complete the moving, one per line. \n\u003cbr\u003e"}},{"title":"Sample Input","value":{"format":"MD","content":"\u003cpre\u003e3 \n4 \n10 20 \n30 40 \n50 60 \n70 80 \n2 \n1 3 \n2 200 \n3 \n10 100 \n20 80 \n30 50 \u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"MD","content":"\u003cpre\u003e10\n20\n30\u003c/pre\u003e"}}]}