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 Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long M = 1_000_000_007;
    int B = scanner.nextInt();
    int W = scanner.nextInt();
    int N = B + W + 1;

    long[] fact = new long[N];
    long[] factinv = new long[N];
    fact[0] = 1;
    for (int i = 1; i < N; i++) fact[i] = fact[i - 1] * i % M;
    factinv[0] = 1;
    for (int i = 1; i < N; i++) factinv[i] = factinv[i - 1] * inverse(i, M) % M;

    long[] w = new long[N];
    for (int i = W; i < N; i++) {
      w[i] = w[i - 1] + choose(i - 1, W - 1, fact, factinv, M) * modpow(2, i * (M - 2), M) % M;
      w[i] %= M;
    }
    long[] b = new long[N];
    for (int i = B; i < N; i++) {
      b[i] = b[i - 1] + choose(i - 1, B - 1, fact, factinv, M) * modpow(2, i * (M - 2), M) % M;
      b[i] %= M;
    }

    StringBuilder sb = new StringBuilder();
    for (int i = 1; i < N; i++) {
      long p = w[i - 1];
      long r = 1 - b[i - 1];
      if (r < 0) r += M;
      r -= w[i - 1];
      if (r < 0) r += M;
      r *= inverse(2, M);
      r %= M;
      p += r;
      p %= M;
      sb.append(p).append('\n');
    }
    System.out.println(sb.toString());
  }

  private static long choose(int n, int k, long[] fact, long[] factinv, long mod) {
    if (n < k) return 0;
    long res = fact[n];
    res *= factinv[k];
    res %= mod;
    res *= factinv[n - k];
    res %= mod;
    return res;
  }

  private static long inverse(long a, long mod) {
    return modpow(a, mod - 2, mod);
  }

  private static long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
      if (n % 2 == 1) res = (res * a) % mod;
      a = (a * a) % mod;
      n >>= 1;
    }
    return res % mod;
  }
}