You need to cover an

rectangle using several

or

dominoes. Each position must be covered exactly once, and the dominoes must not extend outside the rectangle.
Additionally, there may be two types of constraints:
1. The short sides of the dominoes cannot be adjacent, meaning no two dominoes can share a side of length 1.
2. The long sides of the dominoes cannot be adjacent, meaning no two dominoes can share a side of length 2 (even if they only share one edge).
There are

queries, each giving

, representing the size of the rectangle and whether the two constraints exist. When

is 0, the first constraint exists; when

is 1, the first constraint does not exist. When

is 0, the second constraint exists; when

is 1, the second constraint does not exist. For each query, you need to determine if there is a way to cover the entire rectangle.