Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 1000$). The description of the test cases follows.

The first line of each test case contains three integers $n$, $A$, and $B$, denoting the number of cards in your hand, the number of suits in the deck, and the number of ranks in the deck ($1 \le n \le 5000$; $1\le A, B\le 10^9$).

The $i$-th of the following $n$ lines contains two integers $a_i$ and $b_i$ and describes one card, where $a_i$ is the suit of the $i$-th card, and $b_i$ is its rank ($1 \le a_i \le A$; $1 \le b_i \le B$). All the cards in your hand are distinct.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5000$.