#P10949. [2015杭电多校]MZL's combat

[2015杭电多校]MZL's combat

MZL's combat

Problem Description

MZL is an active boy.One day,he is playing a game with DSY and GTW. The combat happened in a chessboard which has RR rows and CC columns.every grid has a parent.the parent of gird (x,y)(x,y) is (x1,y1)(x-1,y-1).the parent of grid (1,y)(1,y) is (1,y1)(1,y-1) and the parent of grid (x,1)(x,1) is (x1,1)(x-1,1),(1,1)(1,1)has no parent. Let's define xx is the ancestor of yy while one of the following conditions meets: 1.x=yx=y 2.xx is the parent of an ancestor of yy Initially the nodes in the chessboard are either white or black.Every player takes turns to act.In each turn,the player can choose a white node and choose one of its ancestors,then the nodes which lies in the path from the chosen node to the chosen ancestor flip its color(white into black,black into white),the player who cannot act loses the game.GTW takes the first turn. Suppose the two players act optimally,DSY wonders whether he will win the game. In consideration of the large size of the chessboard.DSY gives a list of rectangles ,the initial white nodes is the union of the rectangles.

Input

the test data consists several cases.Please read until EOF. the first line are 3 integers n,R,Cn,R,C,means the list size of the rectangles,the number of the rows and the number of the columns. next nn lines ,each line has 4 integers,x1,y1,x2,y2x_1,y_1,x_2,y_2,means the upper left and the lower right nodes of the rectangle. $Cases \leq 16,n,R \leq 10^5,C \leq 10^9,x_1,x_2 \leq R,y_1,y_2\leq C$ And there are 8 big test cases and 8 small test cases

Output

if dsy has a strategy to win,print "DSY wins",otherwise,print "GTW wins"

Sample Input

3 3 3
1 1 3 3
2 1 3 3
2 1 3 1
1 3 3
1 3 2 3

Sample Output

GTW wins
DSY wins

Author

SXYZ

Source

2015 Multi-University Training Contest 5