Under construction

Still being built. Things may change

SolveMe

Time limit8sMemory limit512 MB

Summary
Count pairs of maps A and B on N rooms where following A X times, then B, A Y times, B, and A Z times returns every room to its start, modulo 1,000,000,007.
Level

Hard9 of 10

Topics
Combinatorics, Math, Number theory
Solved
No attempts yet

Problem

There are NN rooms, and each room's floor has a picture of a rabbit. If you stand on the right ear of the rabbit picture in room rr, you teleport onto the tail of the rabbit drawn in room A[r]A[r]. Likewise, standing on the left ear of the rabbit picture in room rr teleports you onto the tail of the rabbit drawn in room B[r]B[r].

You are given integers XX, YY, and ZZ. The cat wants to set the teleports so that the following condition holds. Among the N2NN^{2N} ways to set the teleports, count how many satisfy the condition, modulo 1,000,000,007.

Condition: For every room rr, starting from rr, if you step on the right ear exactly XX times, the left ear exactly once, the right ear exactly YY times, the left ear exactly once, and the right ear exactly ZZ times, you return to rr.

Input

The input is given in the following format:

NN XX YY ZZ

Output

Print the number of teleport settings that satisfy the condition, modulo 1,000,000,007, on a single line.

Constraints

  • NN is between 1 and 1,000, inclusive.
  • XX, YY, and ZZ are between 0 and 1,000,000,000,000,000,000, inclusive.

Examples2

  1. Example 1

    Input
    3 1 0 1
    
    Expected output
    18
    
  2. Example 2

    Input
    5 8 5 8
    
    Expected output
    120