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.
A robot stands at the origin of the xy plane. It faces the positive x direction, and from now on it makes N moves. One move works like this.
The robot turns 90 degrees to the left of its facing with probability L+M+RL, keeps its facing with probability L+M+RM, and turns 90 degrees to the right of its facing with probability L+M+RR. 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.
Once the facing is settled, the robot moves a distance of 1 in that direction.
If the robot ends up at (x,y) after N moves, how far it sits from the origin is measured by x2+y2. Write a program that computes the expected value of that measure after the robot makes N moves.
Input
The first line contains four integers N, L, M, R separated by spaces. N is the number of moves the robot makes, and L, M, R determine the probability of turning left, of keeping the facing, and of turning right. At least one of L, M, R is a positive integer. (1≤N≤109, 0≤L,M,R≤106)
Output
Print the expected value of how far the robot sits from the origin after N moves. For exact judging, write the answer as a reduced fraction a/b and print the remainder of a×b−1 divided by 1,000,000,007 instead. Here b−1 is the multiplicative inverse of b modulo 1,000,000,007. The answer exists for every input that can be given in this problem.