Problem: There is a sheet of paper that can be represented with a grid of size : rows and columns of cells. All cells are colored in white initially.
operations have been applied to the sheet. The -th of them can be described as follows:
- — choose one of non-white colors and color the entire row and the entire column in it. The new color is applied to each cell, regardless of whether the cell was colored before the operation.
The sheet after applying all operations is called a coloring. Two colorings are different if there exists at least one cell that is colored in different colors.
How many different colorings are there? Print the number modulo .
Input Format: The first line contains a single integer () — the number of testcases.
The first line of the testcase contains four integers and () — the size of the sheet, the number of non-white colors and the number of operations.
The -th of the following lines contains a description of the -th operation — two integers and (; ) — the row and the column the operation is applied to.
The sum of over all testcases doesn't exceed .
Output Format: For each testcase, print a single integer — the number of different colorings modulo .