Square Puzzle

Given the pieces of a puzzle, determine if theycan be put together so they form a square of a given size. The pieces may be rotated but not flipped, and all pieces must be used. Pieces may of course not overlap. The pieces to the left can be moved and rotated so they form the square to the right. The shape of the pieces will be given as simple polygons. All vertices will have integer coordinates, and will be given in counter-clockwise direction. The sides of the pieces will either be horizontal, vertical or diagonal. Input The first line in the inputer contains an integer P, the number of puzzles to follow (at most 20). Each puzzle starts with a line containing two integers, n and m (both between 1 and 6, inclusive). n is the number of pieces in the puzzle, while m is the length of the side of the square you want to create. Then follows n lines, each describing a piece. Each line starts with an integer k, the number of vertices in the polygon. Then follows k pair of integers, the x- and y-coordinates for the vertices. All coordinates in a particular puzzle will be between 0 and m, inclusive. Output For each puzzle, output on a single line either ‘yes’ or ‘no’, depending on whether you can form a m×m square using all the pieces. Sample Input 2 56 400303303 3003303 3003303 3006033 3006033 34 51030332414 3002011 51030332414

2/2 Sample Output yes no