Logo
(追記) (追記ここまで)

21259번 - Harmonious Rectangle 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB922100.000%

문제

A vertex-colored rectangle is a rectangle whose four vertices are all painted with colors. For a vertex-colored rectangle, it's harmonious if and only if we can find two adjacent vertices with the same color, while the other two vertices also have the same color with each other.

For example, $\begin{bmatrix} 1 & 0\\ 1 & 0 \end{bmatrix},ドル $\begin{bmatrix} 0 & 0\\ 1 & 1 \end{bmatrix}$ and $\begin{bmatrix} 1 & 1\\ 1 & 1 \end{bmatrix}$ are harmonious, while $\begin{bmatrix} 1 & 0\\ 0 & 1 \end{bmatrix}$ is not (same number for same color, and different numbers for different colors).

For each point in $\{(x,y) | 1 \le x \le n, 1 \le y \le m, x,y \in \mathbb{Z}\},ドル where $\mathbb{Z}$ is the set of all integers, Kotori wants to paint it into one of the three colors: red, blue, yellow. She wonders the number of different ways to color them so that there exists at least one harmonious rectangle formed by the points, whose edges are all parallel to the $x$- or $y$-axis. That is to say, there exists 1ドル \le x_1 < x_2 \le n$ and 1ドル \le y_1 < y_2 \le m$ such that

$$\begin{cases} \text{color}(x_1, y_1) = \text{color}(x_1, y_2)\\ \text{color}(x_2, y_1) = \text{color}(x_2, y_2)\\ \end{cases} $$ or $$\begin{cases} \text{color}(x_1, y_1) = \text{color}(x_2, y_1)\\ \text{color}(x_1, y_2) = \text{color}(x_2, y_2)\\ \end{cases} $$

where $\text{color}(x, y)$ is the color of point $(x, y)$.

Two coloring plans are considered different if there exists a point having different colors in the two coloring plans.

입력

There are multiple test cases. The first line of the input contains an integer $T$ (1ドル \le T \le 10^4$) indicating the number of test cases. For each test case:

The first and only line contains three integers $n,ドル $m$(1ドル \le n, m \le 2 \times 10^3$).

출력

For each test case output one line containing one integer indicating the number of different ways of coloring modulo $(10^9 + 7)$.

제한

예제 입력 1

3
1 4
2 2
3 3

예제 출력 1

0
15
16485

힌트

출처

Contest > Open Cup > 2020/2021 Season > Stage 9: Grand Prix of Nanjing, Division 1 H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /