Problem:
Score : 700 points

Problem Statement

Today, Snuke will eat B pieces of black chocolate and W pieces of white chocolate for an afternoon snack.

He will repeat the following procedure until there is no piece left:

Choose black or white with equal probability, and eat a piece of that color if it exists.

For each integer i from 1 to B+W (inclusive), find the probability that the color of the i-th piece to be eaten is black.
It can be shown that these probabilities are rational, and we ask you to print them modulo 10^9 + 7, as described in Notes.

Notes

When you print a rational number, first write it as a fraction \frac{y}{x}, where x, y are integers and x is not divisible by 10^9 + 7
(under the constraints of the problem, such representation is always possible).
Then, you need to print the only integer z between 0 and 10^9 + 6, inclusive, that satisfies xz \equiv y \pmod{10^9 + 7}.

Constraints

All values in input are integers.

1 \leq B,W \leq 10^{5}

Input

Input is given from Standard Input in the following format:

B W

Output

Print the answers in B+W lines. In the i-th line, print the probability that the color of the i-th piece to be eaten is black, modulo 10^{9}+7.

Sample Input 1

2 1

Sample Output 1

500000004
750000006
750000006

There are three possible orders in which Snuke eats the pieces:

white, black, black

black, white, black

black, black, white

with probabilities \frac{1}{2}, \frac{1}{4}, \frac{1}{4}, respectively. Thus, the probabilities of eating a black piece first, second and third are \frac{1}{2},\frac{3}{4} and \frac{3}{4}, respectively.

Sample Input 2

3 2

Sample Output 2

500000004
500000004
625000005
187500002
187500002

They are \frac{1}{2},\frac{1}{2},\frac{5}{8},\frac{11}{16} and \frac{11}{16}, respectively.

Sample Input 3

6 9

Sample Output 3

500000004
500000004
500000004
500000004
500000004
500000004
929687507
218750002
224609377
303710940
633300786
694091802
172485353
411682132
411682132

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxN = 3e5 + 13, mod = 1e9 + 7;
int b, w, dpw[maxN], dpb[maxN], fac[maxN], rfac[maxN], dpsumw[maxN], dpsumb[maxN];

int pw (int a, int b) {
    int ret = 1;
    for (; b; b >>= 1, a = 1ll * a * a % mod)
	if (b & 1)
	    ret = 1ll * ret * a % mod;
    return ret;
}

int c (int a, int b, int c) {
    return 1ll * fac[a] * rfac[b] % mod * rfac[c] % mod;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> b >> w;
    fac[0] = rfac[0] = 1;
    for (int i = 1; i <= b + w; i++) {
	fac[i] = 1ll * fac[i - 1] * i % mod;
	rfac[i] = 1ll * rfac[i - 1] * pw(i, mod - 2) % mod;
    }
    
    for (int i = w; i < w + b; i++) {
	dpw[i] = 1ll * pw(rfac[2], i) * c(i - 1, w - 1, i - w) % mod;
	//cout << i << " " <<dpw[i] << endl;
	dpsumw[i] = (dpsumw[i - 1] + dpw[i]) % mod;
    }

    for (int i = b; i < w + b; i++) {
	dpb[i] = 1ll * pw(rfac[2], i) * c(i - 1, b - 1, i - b) % mod;
	//cout << i << " " << dpb[i] << endl;
	dpsumb[i] = (dpsumb[i - 1] + dpb[i]) % mod;
    }

    for (int i = 1; i <= w + b; i++) {
	int ans = dpsumw[i - 1];
	if (i != w + b)
	    ans = (ans + 1ll * (1ll - dpsumb[i - 1] - dpsumw[i - 1] + mod + mod) % mod * rfac[2] % mod) % mod;
	cout << i << " " << ans << endl;
    }
}