QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#8750. 连向未来

统计

题目背景

1 是烟消云散的过去。

2 是转瞬即逝的现在。

3 是遥不可及的未来。

过去的迷惘和烦恼连向了现在。如果梦想的热度至今不曾改变,那么不妨将迷惘和烦恼作为宝贵的经验。

现在也终将连向未来。通往未来的大门必定藏在世界上的某个角落。虽然可能无法简单寻得,但若不向前伸出双手,就无从触及。

想要创造从现在开始的崭新的时间,就需要将大家相连。1、2 和 3,缺一不可。只身一人所无法实现的目标,集齐众人的力量就必能跨过。就算形单影只时已足够努力奋斗,如果连在一起时都能各自加倍拼搏,那么不妨同舟共济,同音共律。

题目描述

给定一个 $N\times M$ 的网格。求在每个格子中分别填入 $1$,$2$ 或 $3$ 的方案数,使得填入后存在至少一种将具有公共边的格子分别相连的方案,满足:

  • 每个填有 $1$ 或 $3$ 的格子恰好与相邻的任意一个填有 $2$ 的格子相连;
  • 每个填有 $2$ 的格子恰好与相邻的任意一个填有 $1$ 的格子及任意一个填有 $3$ 的格子分别相连。

输入格式

从标准输入读入数据。

输入第一行包括一个正整数 $T$,表示该测试点中的数据组数。保证 $1\le T\le 100$。

接下来 $T$ 行,每行包含两个由空格隔开的正整数 $N$ 和 $M$,表示网格的大小。保证 $1\le N\le 3$,$1\le M\le 10^9$。

输出格式

输出到标准输出。

对每组数据输出一行,每行包括一个非负整数,表示填数方案数对 $998,244,353$ 取模之后的结果。

样例

输入

5
3 4
2 5
1 6
2 240117
3 378140683

输出

280
0
4
451142875
980338319

提示

不是相遇会带来离别,而是离别会指引新的相遇。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.