{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"Dr. Octopus kidnapped Spiderman\u0027s girlfriend M.J. and kept her in the West Tower. Now the hero, Spiderman, has to reach the tower as soon as he can to rescue her, using his own weapon, the web.\r\u003cbr\u003e\r\u003cbr\u003eFrom Spiderman\u0027s apartment, where he starts, to the tower there is a straight road. Alongside of the road stand many tall buildings, which are definitely taller or equal to his apartment. Spiderman can shoot his web to the top of any building between the tower and himself (including the tower), and then swing to the other side of the building. At the moment he finishes the swing, he can shoot his web to another building and make another swing until he gets to the west tower. Figure-1 shows how Spiderman gets to the tower from the top of his apartment – he swings from A to B, from B to C, and from C to the tower. All the buildings (including the tower) are treated as straight lines, and during his swings he can\u0027t hit the ground, which means the length of the web is shorter or equal to the height of the building. Notice that during Spiderman\u0027s swings, he can never go backwards.\r\u003cbr\u003e\u003ccenter\u003e\u003cimg src\u003d\"CDN_BASE_URL/f7201b241da5cc7b2ccc00ecc0623582?v\u003d1714567768\"\u003e\u003c/center\u003e\r\u003cbr\u003eYou may assume that each swing takes a unit of time. As in Figure-1, Spiderman used 3 swings to reach the tower, and you can easily find out that there is no better way."}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains the number of test cases K (1 \u0026lt;\u003d K \u0026lt;\u003d 20). Each case starts with a line containing a single integer N (2 \u0026lt;\u003d N \u0026lt;\u003d 5000), the number of buildings (including the apartment and the tower). N lines follow and each line contains two integers Xi, Yi, (0 \u0026lt;\u003d Xi, Yi \u0026lt;\u003d 1000000) the position and height of the building. The first building is always the apartment and the last one is always the tower. The input is sorted by Xi value in ascending order and no two buildings have the same X value."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output one line containing the minimum number of swings (if it\u0027s possible to reach the tower) or -1 if Spiderman can\u0027t reach the tower."}},{"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\n6\r\n0 3\r\n3 5\r\n4 3\r\n5 5\r\n7 4\r\n10 4\r\n3\r\n0 3\r\n3 4\r\n10 4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n-1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}