Test instructions
In a grid diagram, each time the deletion of an edge (U,V), and then ask if you can from the U to V, if possible, the output "HAHA", and delete the corresponding side of the situation given, otherwise output "Dajia", and delete the other side
Grid Chart Size <=500
1. By deleting an edge, it is equivalent to connecting the blocks on both sides of the side.
So I thought about it and looked it up.
2. When the two vertices are not connected after the deletion:
That is, block A and block B are already in the same unicom block before the edge is deleted.
Another scenario:
That is, at the edge of the boundary is deleted, it can be seen as a block B and the block number 0 Unicom
Positive solution:
Use and check set to maintain the connectivity of each block, if the two blocks in the same set before the deletion, then two points can not be connected after the deletion, otherwise it will be able to unicom
2018.10.15 Team Test T3