See Problem N for PDF statements.
"The fish who dried the sea went onto land before they did this. They move from one dark forest to another dark forest."
You are now in a

-dimensional universe, which could be seen as an

hyperrectangle. To be specific, let's divide the universe into

hypercubes sized

to describe different regions. The position of each region can be denoted by a

-dimensional integer coordinate
)
where

. Each region owns a

and the initial value is

. However, due to the space war and the abuse of dimensionality weapons, the

of some regions in the universe has decayed to less than

.
Your spaceship is an

hyperrectangle which can also be viewed as

parts of hypercubes sized

. The position of each part can also be denoted by a

-dimensional integer coordinate
)
where

. Each part of your spaceship also owns a

which is initially

. Thanks to advanced technology, some parts of your spaceship are reformed and their

become less than

, which can make them enter the regions with lower

.
We define the spaceship to be in a valid position if the following conditions are met:
- Each part of the spaceship is located exactly in one region.
- Each part of the spaceship cannot have a
strictly higher than the
of the region.
Please calculate the number of different valid positions for your spaceship. Please note that you can't rotate the spaceship.