{"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\"\u003eGiven the finite \u003cb\u003emulti-set\u003c/b\u003e $A$ of $n$ pairs of integers, an another finite \u003cb\u003emulti-set\u003c/b\u003e $B$ of $m$ triples of integers, we define the product of $A$ and $B$ as a \u003cb\u003emulti-set\u003c/b\u003e\u003cbr\u003e\u003cbr\u003e$C \u003dA * B \\\\\u003cbr\u003e \u003d \\{\\langle a,c,d\\rangle \\mid \\langle a,b\\rangle\\in A,~\\langle c,d,e\\rangle\\in B~and~b\u003de\\}$\u003cbr\u003e\u003cbr\u003eFor each $\\langle a,b,c\\rangle\\in C$, its BETTER set is defined as\u003cbr\u003e\u003cbr\u003e$BETTER_C(\\langle a,b,c\\rangle) \u003d \\\\\u003cbr\u003e \\{ \\langle u,v,w\\rangle\\in C \\mid \\langle u,v,w\\rangle \\neq \\langle a,b,c\\rangle,~u\\ge a,~v\\ge b,~w\\ge c \\}$\u003cbr\u003e\u003cbr\u003eAs a \\textbf{multi-set} of triples, we define the TOP subset (as a multi-set as well) of $C$, denoted by $TOP(C)$, as\u003cbr\u003e\u003cbr\u003e$TOP(C) \u003d \\{ \\langle a,b,c\\rangle\\in C \\mid BETTER_C(\\langle a,b,c\\rangle) \u003d \\emptyset \\}$\u003cbr\u003e\u003cbr\u003eYou need to compute the size of $TOP(C)$.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input contains several test cases. The first line of the input is a single integer $t~(1\\le t\\le 10)$ which is the number of test case. Then $t$ test cases follow.\u003cbr\u003e\u003cbr\u003eEach test case contains three lines. The first line contains two integers $n~(1\\le n\\le 10^5)$ and $m~(1\\le m\\le 10^5)$ corresponding to the size of $A$ and $B$ respectively.\u003cbr\u003eThe second line contains $2\\times n$ nonnegative integers\u003cbr\u003e\\[a_1,b_1,a_2,b_2,\\cdots,a_n,b_n\\]\u003cbr\u003ewhich describe the multi-set $A$, where $1\\le a_i,b_i\\le 10^5$.\u003cbr\u003eThe third line contains $3\\times m$ nonnegative integers\u003cbr\u003e\\[c_1,d_1,e_1,c_2,d_2,e_3,\\cdots,c_m,d_m,e_m\\]\u003cbr\u003ecorresponding to the $m$ triples of integers in $B$, where $1\\le c_i,d_i\\le 10^3$ and $1\\le e_i\\le 10^5$."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, you should output the size of set $TOP(C)$."}},{"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\u003e2\r\n5 9\r\n1 1 2 2 3 3 3 3 4 2\r\n1 4 1 2 2 1 4 1 1 1 3 2 3 2 2 4 1 2 2 4 3 3 2 3 4 1 3\r\n3 4\r\n2 7 2 7 2 7\r\n1 4 7 2 3 7 3 2 7 4 1 7\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 5\r\nCase #2: 12\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}