{"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\"\u003e Go is a proverbial board game originated in China. It has been proved to be the most difficult board game in the world. “The rules of Go are so elegant, organic, and rigorously logical that if intelligent life forms exist elsewhere in the universe, they almost certainly play Go.” said Emanuel Lasker, a famous chess master.\u003cbr\u003e A Go board consists of 19 horizontal lines and 19 vertical lines. So there are 361 cross points. At the beginning, all cross points are vacant.\u003cbr\u003e Go is played by two players. The basic rules are:\u003cbr\u003e 1. One player owns black stones and the other owns white stones.\u003cbr\u003e 2. Players place one of his stones on any vacant cross points of the board alternately. The player owns black stones moves first.\u003cbr\u003e 3. Vertically and horizontally adjacent stones of the same color form a chain.\u003cbr\u003e 4. The number of vacant points adjacent (vertically or horizontally) to a chain is called the liberty of this chain. Once the chain has no liberty, it will be captured and removed from the board.\u003cbr\u003e 5. While a player place a new stone such that its chain immediately has no liberty, this chain will be captured at once unless this action will also capture one or more enemy’s chains. In that case, the enemy’s chains are captured, and this chain is not captured.\u003cbr\u003e \u003cbr\u003e In effect, Go also has many advanced and complex rules. However, we only use these basic rules mentioned above in this problem.\u003cbr\u003e Now we are going to deal with another game which is quite similar to Go. We call it “Infinite Go”. The only difference is that the size of the board is no longer 19 times 19 -- it becomes infinite. The rows are numbered 1, 2, 3, ..., from top to down, and columns are numbered 1, 2, 3, ..., from left to right. Notice that the board has neither row 0 nor column 0, which means even though the board is infinite, it has boundaries on the top and on the left.\u003cbr\u003e In this problem, we are solving the problem that, given the actions of two players in a set of Infinite Go, find out the number of remaining stones of each player on the final board.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":" The input begins with a line containing an integer T (1 \u0026lt;\u003d T \u0026lt;\u003d 20), the number of test cases.\u003cbr\u003e For each test case, the first line contains a single integer N (1 \u0026lt;\u003d N \u0026lt;\u003d 10000), the number of stones placed during this set. Then follows N lines, the i-th line contains two integer X and Y (1 \u0026lt;\u003d X, Y \u0026lt;\u003d 2,000,000,000), indicates that the i-th stone was put on row X and column Y (i starts from 1). The stones are given in chronological order, and it is obvious that odd-numbered stones are black and even-numbered ones are white.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":" For each test case, output two integers Nb and Nw in one line, separated by a single space. Nb is the number of black stones left on the board, while Nw is the number of white stones left on the board.\u003cbr\u003e"}},{"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\n7\r\n5 5\r\n4 5\r\n3 5\r\n3 4\r\n4 4\r\n3 3\r\n4 6\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}