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 Rust (1.42.0) (judge verdict: Accepted)

#![allow(clippy::suspicious_arithmetic_impl)]
pub mod mylib {

use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
use std::cmp::PartialEq;

pub trait ToModInt<MOD: ModNumber> {
	fn to_modint(self) -> ModInt<MOD>;
}

pub trait ModNumber : Clone + Copy {
	type ModType: Clone + Copy;
	fn modv() -> u32;
	fn from_bi(x: i64) -> ModInt<Self>;
	fn from_bu(x: u64) -> ModInt<Self>;
	fn from_si(x: i32) -> ModInt<Self>;
	fn from_su(x: u32) -> ModInt<Self>;
	fn direct(x: u32) -> ModInt<Self>;
}
macro_rules! from_bu_prim_to_modint {
	($($im:ty),*) => ($(
		#[inline]
		fn from_bu(x: u64) -> ModInt<$im> {
			let m = <$im>::modv() as u64;
			ModInt::<$im>((x % m) as u32)
		}
	)*)
}
macro_rules! from_bi_prim_to_modint {
	($($im:ty),*) => ($(
		#[inline]
		fn from_bi(i: i64) -> ModInt<$im> {
			let m = <$im>::modv() as i64;
			let mut i = i % m;
			if i < 0 {i += m;}
			ModInt::<$im>((i % m) as u32)
		}
	)*)
}
macro_rules! from_su_prim_to_modint {
	($($im:ty),*) => ($(
		#[inline]
		fn from_su(x: u32) -> ModInt<$im> {
			ModInt::<$im>(x % <$im>::modv())
		}
	)*)
}
macro_rules! from_si_prim_to_modint {
	($($im:ty),*) => ($(
		#[inline]
		fn from_si(x: i32) -> ModInt<$im> {
			let m = <$im>::modv() as i32;
			let mut x = x % m;
			if x < 0 {x += m;}
			ModInt::<$im>(x as u32)
		}
	)*)
}
macro_rules! impl_modint {
	($($im:ty,$fm:block);*) => ($(
		impl ModNumber for $im {
 			type ModType = u32;
			#[inline]
			fn modv() -> u32 $fm
			from_si_prim_to_modint!($im);
			from_su_prim_to_modint!($im);
			from_bi_prim_to_modint!($im);
			from_bu_prim_to_modint!($im);
			#[inline]
			fn direct(x: u32) -> ModInt<$im> {
				ModInt::<$im>(x)
			}
		}
	)*)
}
impl_modint!(RuntimeMod,{unsafe {RUNTIME_MOD}}; Mod107, {1_000_000_007}; Mod998, {998_244_353});


#[derive(Clone, Copy)]
pub struct RuntimeMod {}
impl RuntimeMod {
	pub fn set(x: u32) {
		unsafe {
			RUNTIME_MOD = x;
		}
	}
}
#[derive(Clone, Copy)]
pub struct Mod107 {}
#[derive(Clone, Copy)]
pub struct Mod998 {}
#[derive(Clone, Copy)]
pub struct ModInt<MOD: ModNumber> (pub MOD::ModType);

macro_rules! impl_to_modint_bi {
	($($t:ty)*) => ($(
		impl <MOD: ModNumber> ToModInt<MOD> for $t {
			#[inline]
			fn to_modint(self) -> ModInt<MOD> {
				<MOD>::from_bi(self as i64)
			}
		}
	)*)
}
macro_rules! impl_to_modint_si {
	($($t:ty)*) => ($(
		impl <MOD: ModNumber> ToModInt<MOD> for $t {
			#[inline]
			fn to_modint(self) -> ModInt<MOD> {
				<MOD>::from_si(self as i32)
			}
		}
	)*)
}
macro_rules! impl_to_modint_bu {
	($($t:ty)*) => ($(
		impl <MOD: ModNumber> ToModInt<MOD> for $t {
			#[inline]
			fn to_modint(self) -> ModInt<MOD> {
				<MOD>::from_bu(self as u64)
			}
		}
	)*)
}
macro_rules! impl_to_modint_su {
	($($t:ty)*) => ($(
		impl <MOD: ModNumber> ToModInt<MOD> for $t {
			#[inline]
			fn to_modint(self) -> ModInt<MOD> {
				<MOD>::from_su(self as u32)
			}
		}
	)*)
}

impl_to_modint_si!(i8 i16);
impl_to_modint_bu!(u32 u64);
impl_to_modint_su!(u8 u16);
impl_to_modint_bi!(i32 i64);

static mut RUNTIME_MOD: u32 = 0;
impl<MOD: ModNumber> ModInt<MOD> {}
impl<MOD: ModNumber> ModInt<MOD> 
where 
	ModInt<MOD>: MulAssign
{
	pub fn pow(self, mut p: u64) -> Self {
		let mut res = <MOD>::direct(1);
		let mut m = self;
		while p != 0 {
			if p & 1 == 1 {
				res *= m;
			}
			p >>= 1;
			m *= m;
		}
		res
	}
}
macro_rules! impl_modints {
	($($m:ty)*) => ($(
		impl Add<ModInt<$m>> for ModInt<$m> {
			type Output = ModInt<$m>;
			fn add(self, rhs: ModInt<$m>) -> ModInt<$m> {
				ModInt::<$m>((self.0 + rhs.0) % <$m>::modv())
			}
		}
		impl AddAssign<ModInt<$m>> for ModInt<$m> {
			fn add_assign(&mut self, rhs: ModInt<$m>) {
				*self = *self + rhs;
			}
		}
		impl Sub<ModInt<$m>> for ModInt<$m> {
			type Output = ModInt<$m>;
			fn sub(self, rhs: ModInt<$m>) -> ModInt<$m> {
				let mut x = self.0 as i32 - rhs.0 as i32;
				if x < 0 {x += <$m>::modv() as i32}
				ModInt::<$m>(x as u32 % <$m>::modv())
			}
		}
		impl SubAssign<ModInt<$m>> for ModInt<$m> {
			fn sub_assign(&mut self, rhs: ModInt<$m>) {
				*self = *self - rhs;
			}
		}
		impl Mul<ModInt<$m>> for ModInt<$m> {
			type Output = ModInt<$m>;
			fn mul(self, rhs: ModInt<$m>) -> ModInt<$m> {
				let x = self.0 as u64 * rhs.0 as u64;
				ModInt::<$m>((x % <$m>::modv() as u64) as u32)
			}
		}
		impl MulAssign<ModInt<$m>> for ModInt<$m> {
			fn mul_assign(&mut self, rhs: ModInt<$m>) {
				*self = *self * rhs;
			}
		}
		impl Div<ModInt<$m>> for ModInt<$m> {
			type Output = ModInt<$m>;
			fn div(self, rhs: ModInt<$m>) -> ModInt<$m> {
				self * rhs.pow((<$m>::modv() - 2) as u64)
			}
		}
		impl DivAssign<ModInt<$m>> for ModInt<$m> {
			fn div_assign(&mut self, rhs: ModInt<$m>) {
				*self = *self / rhs;
			}
		}
		impl PartialEq<ModInt<$m>> for ModInt<$m> {
			fn eq(&self, rhs: &ModInt<$m>) -> bool {
				self.0 == rhs.0
			}
		}
	)*)
}
impl_modints!(Mod107 Mod998 RuntimeMod);
macro_rules! impl_modint_primint {
	($m:ty, $($t:ty)*) => ($(
		impl Add<$t> for ModInt<$m> {
			type Output = ModInt<$m>;
			fn add(self, rhs: $t) -> ModInt<$m> {
				self + rhs.to_modint()
			}
		}
		impl AddAssign<$t> for ModInt<$m> {
			fn add_assign(&mut self, rhs: $t) {
				*self = *self + rhs;
			}
		}
		impl Sub<$t> for ModInt<$m> {
			type Output = ModInt<$m>;
			fn sub(self, rhs: $t) -> ModInt<$m> {
				self - rhs.to_modint()
			}
		}
		impl SubAssign<$t> for ModInt<$m> {
			fn sub_assign(&mut self, rhs: $t) {
				*self = *self - rhs;
			}
		}
		impl Mul<$t> for ModInt<$m> {
			type Output = ModInt<$m>;
			fn mul(self, rhs: $t) -> ModInt<$m> {
				self * rhs.to_modint()
			}
		}
		impl MulAssign<$t> for ModInt<$m> {
			fn mul_assign(&mut self, rhs: $t) {
				*self = *self * rhs;
			}
		}
		impl Div<$t> for ModInt<$m> {
			type Output = ModInt<$m>;
			fn div(self, rhs: $t) -> ModInt<$m> {
				self / rhs.to_modint()
			}
		}
		impl DivAssign<$t> for ModInt<$m> {
			fn div_assign(&mut self, rhs: $t) {
				*self = *self / rhs;
			}
		}
	)*)
}
impl_modint_primint!(    Mod107, u8 u16 u32 u64 i8 i16 i32 i64);
impl_modint_primint!(    Mod998, u8 u16 u32 u64 i8 i16 i32 i64);
impl_modint_primint!(RuntimeMod, u8 u16 u32 u64 i8 i16 i32 i64);

} // mod mylib

use proconio::input;
type ModType = mylib::RuntimeMod;
// type ModType = mylib::Mod107;
// type ModType = mylib::Mod998;
type ModInt = mylib::ModInt<ModType>;

#[inline]
fn modint<T: mylib::ToModInt<ModType>>(x: T) -> ModInt {
	x.to_modint()
}

use proconio::fastout;

#[fastout]
fn main() {
	mylib::RuntimeMod::set(1_000_000_007);
	input! {
		b: usize,
		w: usize
	}
	let n = b + w;
	let mut fact = vec![modint(1); n];
	for i in 1..n {
		fact[i] = fact[i-1] * i as u32;
	}
	let comb = |n: usize, r: usize| fact[n] / fact[r] / fact[n-r];
	let mut p = modint(0);
	let mut q = modint(0);

	for i in 1..n+1 {
		println!("{}", ((modint(1) - p + q) / modint(2)).0);
		if i >= b {
			p += comb(i-1, b-1) / modint(2).pow(i as u64);
		}
		if i >= w {
			q += comb(i-1, w-1) / modint(2).pow(i as u64);
		}
	}
}