{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eThere is an infinite square grid. Some vertices of the grid are black and other vertices are white.\u003c/p\u003e\u003cp\u003eA vertex \u003ci\u003eV\u003c/i\u003e is called \u003ci\u003einner\u003c/i\u003e if it is both vertical-inner and horizontal-inner. A vertex \u003ci\u003eV\u003c/i\u003e is called \u003ci\u003ehorizontal-inner\u003c/i\u003e if there are two such black vertices in the same row that \u003ci\u003eV\u003c/i\u003e is located between them. A vertex \u003ci\u003eV\u003c/i\u003e is called \u003ci\u003evertical-inner\u003c/i\u003e if there are two such black vertices in the same column that \u003ci\u003eV\u003c/i\u003e is located between them.\u003c/p\u003e\u003cp\u003eOn each step all white inner vertices became black while the other vertices preserve their colors. The process stops when all the inner vertices are black.\u003c/p\u003e\u003cp\u003eWrite a program that calculates a number of black vertices after the process stops.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eThe first line of the input file contains one integer number \u003ci\u003en\u003c/i\u003e (0 ≤ \u003ci\u003en\u003c/i\u003e ≤ 100 000) — number of black vertices at the beginning.\u003c/p\u003e\u003cp\u003eThe following \u003ci\u003en\u003c/i\u003e lines contain two integer numbers each — the coordinates of different black vertices. The coordinates do not exceed 10\u003csup\u003e9\u003c/sup\u003e by their absolute values.\u003c/p\u003e\u003c/span\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eOutput the number of black vertices when the process stops. If the process does not stop, output \u003ccode\u003e-1\u003c/code\u003e.\u003c/p\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\u003e4\r\n0 2\r\n2 0\r\n-2 0\r\n0 -2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cdiv align\u003d\"center\"\u003e\u003cimg src\u003d\"CDN_BASE_URL/19b7207cf07cc68d61505e691c646f69?v\u003d1714103993\"\u003e\u003c/div\u003e"}}]}