|Time limit : 5 s||Memory limit : 32 mb|
|Submitted : 369||Accepted : 178|
The Ministry of housing is planning a huge construction project of several housing complexes. Each complex includes several apartments to be sold to government employees at reasonable prices. The ministry has located several big m * n pieces of land that can potentially be used for such construction project; one complex in each land. The lands are all rectangular, each with m * n number of 1 * 1 square blocks. All housing complexes are h * w rectangles covering exactly h * w blocks of each containing land.
The problem is that there are originally some old buildings, each covering exactly one block of a land, making it impossible to locate enough free space for all the complexes in order to start the project. Therefore, the ministry has to buy some of these buildings, and demolish them to free the needed space. The old buildings belong to certain number of people. These people are angry of the possibility that their building may be bought and demolished, especially because the government usually pays much less for their buildings compared to the open market prices.
In response to the protests, the ministry announces a "fair" decision that if it buys some buildings in one land, it will only choose those that belong only to one owner, and will buy all of them at reasonable price. And, it promises not to buy buildings belonging to the same owner in other lands. Note that with this constraint, there may be some lands in which building a complex is impossible. Trying to keep its promises, the ministry has asked you to write a program to see how many housing complexes can be constructed at most with these conditions.
2 3 4 3 3 2 A0B 000 0A0 00B AA0 00B 0B0 000 A0A 000 B00 B00 3 4 3 3 2 A0B 000 0A0 00B AA0 00B 0B0 000 A0A 000 0B0 B00