{"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\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eA movie company has released $$$2$$$ movies. These $$$2$$$ movies were watched by $$$n$$$ people. For each person, we know their attitude towards the first movie (liked it, neutral, or disliked it) and towards the second movie.\u003c/p\u003e\u003cp\u003eIf a person is asked to leave a review for the movie, then: \u003c/p\u003e\u003cul\u003e \u003cli\u003e if that person liked the movie, they will leave a positive review, and the movie\u0027s rating will increase by $$$1$$$; \u003c/li\u003e\u003cli\u003e if that person disliked the movie, they will leave a negative review, and the movie\u0027s rating will decrease by $$$1$$$; \u003c/li\u003e\u003cli\u003e otherwise, they will leave a neutral review, and the movie\u0027s rating will not change. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eEvery person will review exactly one movie — and for every person, you can choose which movie they will review.\u003c/p\u003e\u003cp\u003eThe company\u0027s rating is the minimum of the ratings of the two movies. Your task is to calculate the maximum possible rating of the company.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u0026nbsp;— the number of test cases.\u003c/p\u003e\u003cp\u003eThe first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$).\u003c/p\u003e\u003cp\u003eThe second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$-1 \\le a_i \\le 1$$$), where $$$a_i$$$ is equal to $$$-1$$$ if the first movie was disliked by the $$$i$$$-th viewer; equal to $$$1$$$ if the first movie was liked; and $$$0$$$ if the attitude is neutral.\u003c/p\u003e\u003cp\u003eThe third line contains $$$n$$$ integers $$$b_1, b_2, \\dots, b_n$$$ ($$$-1 \\le b_i \\le 1$$$), where $$$b_i$$$ is equal to $$$-1$$$ if the second movie was disliked by the $$$i$$$-th viewer; equal to $$$1$$$ if the second movie was liked; and $$$0$$$ if the attitude is neutral.\u003c/p\u003e\u003cp\u003eAdditional constraint on the input: the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, print a single integer\u0026nbsp;— the maximum possible rating of the company, if for each person, choose which movie to leave a review on.\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\u003e4\n2\n-1 1\n-1 -1\n1\n-1\n-1\n5\n0 -1 1 0 1\n-1 1 0 0 1\n4\n-1 -1 -1 1\n-1 1 1 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n-1\n1\n1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}