Knights

Given an n × m chess board, you can place on it as many black knights as
you wish, as long as no two knights threaten each other. How many
possibilities do you have?

For instance, these are just four of the 278 possibilities for n = 3 and
m = 4:

Input

Input consists of several cases, each with n and m. Assume 1 ≤ n ≤ 4 and
1 ≤ m ≤ 10¹⁵.

Output

For every case, print the number of possibilities modulo 10⁸ + 7.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T10:25:19.607Z

© Jutge.org, 2006–2026.
https://jutge.org
