atcoder#AGC053F. [AGC053F] ESPers

[AGC053F] ESPers

Score : 24002400 points

Problem Statement

2N+12N+1 players will play a game called Majority Vote. Each player casts a vote to one of the two options given, and the players choosing the option that ends up with the greater number of votes will win. The detailed progression of the vote is as follows:

  1. If everyone has already voted, the vote ends. Otherwise, proceed to step 2.
  2. One player is chosen randomly among the players who have not voted, and s/he casts a vote. Then, go back to step 1.

KK of the players are ESPers, who can know the number of votes cast to each option when they cast votes. Thus, the players choose the option to cast as follows:

  • A player who is an ESPer chooses the option with the greater number of votes at the moment. If the two options have the same number of votes, s/he chooses one option randomly and votes for it.
  • A player who is not an ESPer randomly chooses one option and votes for it.

X is a player of the game who is also an ESPer. Find the probability that X wins, modulo (109+7)(10^9+7) (see Notes).

Notes

  • The expected value in question will be a rational number. If we express it as a fractional number yx\frac{y}{x} where xx and yy are coprime positive integers, xx will be coprime with P=109+7P=10^9+7, so print the only integer zz between 00 and P1P-1 (inclusive) such that xzy(modP)xz \equiv y \pmod P.

Constraints

  • 1N2×1061 \leq N \leq 2\times 10^6
  • 1K2N+11 \leq K \leq 2N+1

Input

Input is given from Standard Input in the following format:

NN KK

Output

Print the answer.

1 1
916666674

X wins with probability 1112\frac{11}{12}.

1 2
958333341

X wins with probability 2324\frac{23}{24}.

8 5
582281799
100 100
196654831
2000000 2000000
768385859