QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#10809. 网格涂色

统计

Bob 喜欢给网格涂色。今天,他想把一个 $n \times m$ 网格中的每个格子都涂成黑色或白色。Bob 认为,如果没有任何三个连续的格子颜色相同(无论是在水平、垂直还是对角线方向上),那么这种涂色方式就是“美丽的”。以下是一些示例以帮助你理解:

(1)、(2)、(4) 不是美丽的,而 (3)、(5) 是美丽的。

现在问题来了:给定 $n$ 和 $m$,你能告诉 Bob 有多少种美丽的涂色方式吗?设答案为 $x$,你只需要输出 $x \pmod{1\,000\,000\,007}$。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 20$),表示查询的数量。 接下来的 $T$ 行,每行包含两个整数 $n, m$ ($1 \le n, m \le 10^9$),表示一个查询。

输出格式

对于每个查询,输出一行答案。

样例

输入 1

6
1 1
2 2
2 3
3 3
3 4
4 4

输出 1

2
16
36
32
44
18

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.