Old man Vasyl, a new Ukrainian farmer, owns a rectangular plot of land measuring by . This plot is divided into unit squares, each growing a variety of rice. For simplicity, these rice varieties are numbered from to N \times M.
Recently, Vasyl secured a contract with the International Rice Corporation (IPC) for days. Under this agreement, he must deliver rice of a specified variety each day.
When the IPC requests rice of variety , Vasyl follows a specific strategy: he identifies the largest possible rectangular area on his by plot where only rice of variety is grown. Vasyl harvests rice exclusively from these rectangular areas.
For the IPC, it's crucial to know the maximum quantity of rice Vasyl can supply for each request. From each unit square, Vasyl harvests one unit of rice, meaning from an area of size , he collects units of rice. Additionally, Vasyl can repeatedly harvest rice from a given area as many times as needed.
The first line contains two integers and , 1 \leq N, M \leq 1000 – the dimensions of Vasyl's plot. The following lines each contain integers, a_{ij} – the variety of rice growing in the -th square of the -th row, 1 \leq a_{ij} \leq N \times M.
Next, the number is provided – the number of days Vasyl must supply rice to the company, 1 \leq T \leq 20. The following lines each contain one integer – the variety of rice ordered by the company, 1 \leq K \leq N \times M.
Output numbers, each representing the maximum amount of rice Vasyl can collect for each request from the IPC company.
Example 1