传统题 3000ms 512MiB

Enlighten the Grid

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

Natural and Larutan live in the beautiful River City, through which the Yangtze River flows. To decorate the riverbank, Larutan installed an n×mn\times m grid of lights. Initially, all the lights are off.

Natural designed a controller for these lights. In one operation, he chooses a cell and toggles the light in that cell, as well as the lights in the cells directly above, below, to the left, and to the right, provided those cells are within the grid. Each cell may be chosen at most once.

The order of the operations does not affect the final state. Two operation schemes are considered different if they choose different sets of cells. Natural wants to know how many schemes turn on every light in the grid. Output the answer modulo ModMod.

Input Format

The input contains three integers nn, mm, and ModMod, where nn and mm are the number of rows and columns in the grid, respectively.

Output Format

Output one integer: the number of valid operation schemes modulo ModMod.

Samples

Input #1

2 1 998244353

Output #1

2

Input #2

2 2 998244353

Output #2

1

Input #3

341 741327521 998244353

Output #3

360709869

Sample Explanation

In the first sample, choosing either one of the two cells toggles both lights, so there are two valid schemes.

In the second sample, the only valid scheme is to choose all four cells.

Constraints

For all test cases:

  • 1n4001\leq n\leq 400;
  • 1m1091\leq m\leq 10^9;
  • 1Mod1091\leq Mod\leq 10^9.

Hello ACM 2026

未参加
状态
已结束
规则
ACM/ICPC
题目
13
开始于
2026-8-15 13:00
结束于
2026-8-15 18:00
持续时间
5 小时
主持人
参赛人数
31