Robot

Compute the expected squared distance from the origin after a robot takes N probabilistic left, straight, or right moves, and print it as a fraction modulo 1e9+7.

Medium6ProbabilityMathDynamic programmingNo attempts yetTime limit1sMemory limit512 MB

Problem

A robot stands at the origin of the xy plane. It faces the positive x direction, and from now on it makes NN moves. One move works like this.

  1. The robot turns 90 degrees to the left of its facing with probability LL+M+R\frac{L}{L+M+R}, keeps its facing with probability ML+M+R\frac{M}{L+M+R}, and turns 90 degrees to the right of its facing with probability RL+M+R\frac{R}{L+M+R}. From the starting state, a left turn makes it face the positive y direction and a right turn makes it face the negative y direction.
  2. Once the facing is settled, the robot moves a distance of 1 in that direction.

If the robot ends up at (x,y)(x, y) after NN moves, how far it sits from the origin is measured by x2+y2x^2 + y^2. Write a program that computes the expected value of that measure after the robot makes NN moves.

Input

The first line contains four integers NN, LL, MM, RR separated by spaces. NN is the number of moves the robot makes, and LL, MM, RR determine the probability of turning left, of keeping the facing, and of turning right. At least one of LL, MM, RR is a positive integer. (1N1091 \le N \le 10^9, 0L,M,R1060 \le L, M, R \le 10^6)

Output

Print the expected value of how far the robot sits from the origin after NN moves. For exact judging, write the answer as a reduced fraction a/ba/b and print the remainder of a×b1a \times b^{-1} divided by 1,000,000,007 instead. Here b1b^{-1} is the multiplicative inverse of bb modulo 1,000,000,007. The answer exists for every input that can be given in this problem.