{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"Read problems statements in Mandarin Chinese \u003ca target\u003d\"_blank\" rel\u003d\"noreferrer noopener\"\u003ehere\u003c/a\u003e\n\nCity of Byteland can be described as a $2D$ grid of cells. Each cell may or may not contain a demon. You are given the list of cells that contain demons.\n\nIn a single Kamehameha attack, Goku can kill all the demons standing in a row or in a column. But using Kamehameha drains Goku\u0027s power. You are to tell the minimum number of Kamehameha attacks that will be required by Goku to destroy all the demons.\n\n### Input\n- The first line contains a single integer $T$, the number of test cases. The description of the test cases follows.\n- The first line of each test case contains a single integer $N$, the number of cells where enemies are present. The description of the enemies follows.\n- The next $N$ lines contain two space separated integers $X$ and $Y$, the row and column of the cell in which a demon is present.\n\n### Output\nFor each test case, on a new line, print the minimum number of attacks that are required to kill all of the demons.\n\n### Constraints\n- $1 \\leq T \\leq 10$\n- $1 \\leq N \\leq 1000$\n- $1 \\leq X, Y \\leq 10^9$"}},{"title":"Sample 1","value":{"format":"MD","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\n3\n0 0\n1 0\n0 1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}