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 (GCC 5.4.1) (judge verdict: Runtime Error)

#include <stdio.h>

#define MOD 1000000007LL

long long fact[100010], factinv[100010];

void factorial(void) {
	int i, j;
	long long P, Q, R, EXP;
 
	fact[0] = 1; factinv[0] = 1;
	for (i=1;i<=100010;i++) {
		fact[i] = fact[i-1];
		fact[i] *= i;
		fact[i] %= MOD;
 
		factinv[i] = factinv[i-1];
		P = 1;
		Q = i;
		EXP = 1000000005LL;
		while (EXP>0) {
			if (EXP & 1) P *= Q;
			Q *= Q;
			EXP >>= 1;
			P %= MOD;
			Q %= MOD;
		}
		factinv[i] *= P;
		factinv[i] %= MOD;
	}
 
}

long long comb_mod(int a, int b) {
	long long P=1;
	P = P * fact[a];
	P = P * factinv[a-b] % MOD;
	P = P * factinv[b]   % MOD;
	return P;
}

long long print_ratio(long long y, long long x) {
    // x assumed exponent of 2
    long long z, prod, t;
    prod = 1LL; t = 2LL;
    z = MOD - 1 - x;
    while (z) {
        if (z & 1) prod = prod*t % MOD;
        t = t*t % MOD;
        z >>= 1;
    }
    return prod*y%MOD;
}

int main(void) {
    int i, B, W;
    long long z, denom, num, black[200010], white[200010];
    factorial();
    scanf("%d%d", &B, &W);
    black[0] = 0LL;
    white[0] = 0LL;
    for (i=1;i<=B+W;i++) {
//        denom = i-1;
        if (i<B) { black[i] = 0LL; }
        else {
            num = black[i-1] + print_ratio(comb_mod(i-1,B-1), i);
            black[i] = num % MOD;
        }

        if (i<W) { white[i] = 0LL; }
        else {
            num = white[i-1] + print_ratio(comb_mod(i-1,W-1),i);
            white[i] = num % MOD;
        }

    }
    for (i=0;i<B+W;i++) {
        printf("%9lld ", black[i]);
    }
    printf("\n");
    for (i=0;i<B+W;i++) {
        printf("%9lld ", white[i]);
    }
    printf("\n");
    // printf("%lld\n", binomial(3,1));

    for (i=1;i<=B+W;i++) {
        z = print_ratio(1,1) - print_ratio(black[i-1],1) + print_ratio(white[i-1],1) + MOD;
        // printf("%10lld/%10lld\n", num, denom);
        printf("%lld\n", z % MOD);
    }

    return 0;
}