#P7689. [CEOI 2002] Bugs Integrated,Inc.
[CEOI 2002] Bugs Integrated,Inc.
Description
Bugs Integrated,Inc. is a major manufacturer of high-end memory chips. They are starting production of a new TB Q-RAM chip. Each chip consists of six square silicon blocks arranged in a rectangle. Q-RAM chips are manufactured by cutting a large rectangular silicon wafer into square silicon blocks. Then all square silicon blocks are carefully tested, and the defective ones are marked in black.

Finally, the wafer is cut into memory chips. Each chip consists of (or ) unit square silicon blocks. Of course, no chip may contain any defective (marked) square silicon blocks. It may be impossible to cut the wafer so that every good square silicon block becomes part of some memory chip. The company wants to waste as few good square silicon blocks as possible. Therefore, they want to know how to cut the wafer to produce as many chips as possible.
You are given the sizes of several wafers and the list of all defective square silicon blocks on each wafer. Your task is to write a program that computes, for each wafer, the maximum number of chips that can be cut from it.
Input Format
The first line contains an integer , the number of wafers. Then follow sections, each describing one wafer.
The first line of each section contains three integers , , and , separated by single spaces. is the width of the wafer, is its height, and is the number of defective square silicon blocks on the wafer.
The next lines list the defective square silicon blocks. Each line contains two integers and , giving the coordinates of one defective square silicon block (the top-left corner is , and the bottom-right corner is ).
Output Format
For each wafer, output one line with the maximum number of chips that can be cut from it.
2
6 6 5
1 4
4 6
2 2
3 6
6 4
6 5 4
3 3
6 1
6 2
6 4
3
4
Hint
Constraints
For of the testdata, , , , , , 。
Sample Explanation

Problem Notes
From CENTRAL-EUROPEAN OLYMPIAD IN INFORMATICS 2002: Bugs Integrated,Inc.。
Translated and organized by @求学的企鹅。
Translated by ChatGPT 5
京公网安备 11011102002149号