Traffic Jam

The kingdom of Tripbansai has an unusual traffic system. The city locations in the kingdom can be described as a grid and all the roads connect neighboring cities. This rectangular grid has 2 rows and C columns where every point represents a city. So there are 2 ∗ C cities and 3 ∗ C − 2 roads in this system. Sometimes two adjacent cities become disconnected because of traffic jam, and sometimes the traffic problem has been solved so that a road can be used again. We can assume that every road is closed at first. Ministry of Communications will give some instructions to you. Your task is to implement a program as a traffic response information system. Each instruction Close r1 c1 r2 c2 Open r1 c1 r2 c2 Ask r1 c1 r2 c2 Exit Input The first line of the cases that follow. appears as a single line in one of the formats below: Close the road connecting the adjacent cities located on (r1,c1) and (r2,c2). Open the road connecting the adjacent cities located on (r1, c1) and (r2, c2). Reply with ‘Y’ if there exists a way from the city on (r1,c1) to the city on (r2,c2); reply with ‘N’ if there doesn’t. No more requests are forthcoming. The problem should exit. input contains a single integer T (1 ≤ T ≤ 11), representing the number of test The first line of each test case consists of a single integer C (1 ≤ C ≤ 100000), which is the number of columns. There are some lines following, each for an instruction. Each test case ends with an instruction ‘Exit’. There are no more than 100000 instructions in each test case. All the roads are closed initially, and each case is an independent problem. Output For each instruction ‘Ask r1 c1 r2 c2’, display a line containing ‘Y’ or ‘N’. Sample Input 3 2 Open 1 1 1 2 Open 1 2 2 2 Ask 1 1 2 2 Ask 2 1 2 2 Exit 3 Open 1 1 1 2 Ask 1 1 1 2 Close 1 1 1 2 Ask 1 1 1 2 Exit

2/2 2 Open 1 1 1 2 Open 1 2 2 2 Open 2 1 2 2 Ask 1 1 2 1 Exit Sample Output Y N Y N Y