In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].

If you are familiar with IRC chat, the support team is also reachable on PIRC network (`irc.pirc.pl`

) in `#szkopul`

channel. If you are not, just use email.

Please do not ask us things like "how to solve task XYZ?".

Please remember that the support team has to sleep sometimes or go to work in real life.

A Byteotian ant is walking along the edges of ABCDEFGH cube:

It tries to find out, in how many ways it can go from one given vertex, to another given vertex, walking along exactly edges (when the ant enters an edge, it will not turn back and will finally reach the second end of this edge). If the ant goes through some edge times, we count this edge times. The ant would like to have interesting routes, that is if the ant is in some vertex, it would like to leave this vertex using an edge other than the edge recently used to enter this vertex (i.e. it want not to use the same edge twice in a row).

Our ant is not so smart, because it can only count using integers from to , for some , so you should compute the result modulo .

Write a program which:

- reads the starting and the ending vertex of the ant's route, number of edges on the ant's route, and integer ,
- computes number of interesting routes, which satisfy the ant's requests, modulo ,
- writes the answer to the standard output.

The first line of the standard input contains two capital English letters and (, ), separated by a single space. The two letters denote the starting and ending vertex of the ant's route respectively. The second line contains two integers and (, ), separated by a single space.

Exactly one integer is to be written on the standard output. This integer is the number of interesting routes from the vertex to the vertex , containing exactly edges, modulo .

For the input data:

A B 3 100

the correct result is:

2

*Task author: Jakub Radoszewski.*