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.15.1) (judge verdict: Wrong Answer)

pub mod mylib {
use std;
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
use std::cmp::PartialEq;
use std::str::FromStr;
use std::num::ParseIntError;
use std::fmt::{Display, Formatter};

#[macro_use]
mod macros {
macro_rules! impl_to_modint {
	($($t:ty)*) => ($(
		impl <MOD: ModNumber> ToModInt<MOD> for $t {
			#[inline]
			fn to_modint(self) -> ModInt<MOD> {
				if <$t>::min_value() == 0 {
					<MOD>::from_bu(self as u64)
				} else {
					<MOD>::from_bi(self as i64)
				}
			}
		}
	)*)
}
macro_rules! impl_modint {
	($($im:ty),*) => ($(
		impl ModNumber for $im {
 			type ModType = u32;
			#[inline]
			from_bi_prim_to_modint!($im);
			from_bu_prim_to_modint!($im);
			#[inline]
			fn direct(x: u32) -> ModInt<$im> {
				ModInt::<$im>(x)
			}
		}
	)*)
}

macro_rules! from_bu_prim_to_modint {
	($($im:ty),*) => ($(
		#[inline]
		fn from_bu(x: u64) -> ModInt<$im> {
			let ret_type = ModInt::<$im>(0 as u32);
			let m = ret_type.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 ret_type = ModInt::<$im>(0 as u32);
			let m = ret_type.modv() as i64;
			let mut i = i % m;
			if i < 0 {i += m;}
			ModInt::<$im>((i % m) as u32)
		}
	)*)
}

macro_rules! impl_modint_operators {
	($($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) % self.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 += self.modv() as i32}
				ModInt::<$m>(x as u32 % self.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 % self.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((self.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
			}
		}
	)*)
}
macro_rules! impl_modint_fromstr {
	($($m:ty),*) => ($(
		impl FromStr for ModInt<$m> {
			type Err = ParseIntError;
			fn from_str(s: &str) -> Result<Self, Self::Err> {
				if s.bytes().next() == Some(b'-') {
					Ok(<$m>::from_bi(s.parse::<i64>()?))
				} else {
					Ok(<$m>::from_bu(s.parse::<u64>()?))
				}
			}
		}
	)*)
}
macro_rules! impl_modint_display {
	($($m:ty),*) => ($(
		impl Display for ModInt<$m> {
			fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
				write!(f, "{}", self.0)
			}
		}
	)*)
}
} // mod macros

pub trait ToModInt<MOD: ModNumber> {
	fn to_modint(self) -> ModInt<MOD>;
}
impl_to_modint!(i8 i16 i32 i64 u8 u16 u32 u64 usize isize);

pub trait ModNumber : Clone + Copy {
	type ModType: Clone + Copy;
	fn from_bi(x: i64) -> ModInt<Self>;
	fn from_bu(x: u64) -> ModInt<Self>;
	fn direct(x: u32) -> ModInt<Self>;
}

impl_modint!(RuntimeMod, Mod107, Mod998);


static mut RUNTIME_MOD: u32 = 0;
#[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);

pub trait ModIntTrait<MOD: ModNumber> {
	fn modv(&self) -> MOD::ModType;
}
impl ModIntTrait<Mod107> for ModInt<Mod107> {fn modv(&self) -> <Mod107 as ModNumber>::ModType {1_000_000_007}}
impl ModIntTrait<Mod998> for ModInt<Mod998> {fn modv(&self) -> <Mod998 as ModNumber>::ModType {1_000_000_007}}
impl ModIntTrait<RuntimeMod> for ModInt<RuntimeMod> {fn modv(&self) -> <RuntimeMod as ModNumber>::ModType {unsafe {RUNTIME_MOD}}}

impl_modint_operators!(Mod107 Mod998 RuntimeMod);

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
	}
}

impl_modint_fromstr!(RuntimeMod, Mod107, Mod998);

impl_modint_display!(RuntimeMod, Mod107, Mod998);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_io() {
        let input = br"10
        1 2 3 4 5 6 7 8 9 10
        abcde fghij
        
        3.14 -1592
        no_empty_line";
        let mut sc = IO::new(&input[..], Vec::new());

        let n: usize = sc.read();
        assert_eq!(n, 10);

        let a: Vec<u64> = sc.vec(n);
        assert_eq!(&a, &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

        let s = sc.chars();
        let t = sc.chars();
        assert_eq!(&s, &['a', 'b', 'c', 'd', 'e']);
        assert_eq!(&t, &['f', 'g', 'h', 'i', 'j']);

        let f: f64 = sc.read();
        assert_eq!(f, 3.14);

        let neg: i64 = sc.read();
        assert_eq!(neg, -1592);

        let s = sc.read::<String>();
        assert_eq!(&s, "no_empty_line");
        sc.write(format!("1\n"));

        let mut output = Vec::new();
        {
            let mut sc = IO::new(&b""[..], &mut output);
            sc.write(format!("{}\n", 1));
            sc.write(format!("{}\n", 2));
            sc.write(format!("{}\n", 3));
        }

        let output = String::from_utf8(output).expect("Not UTF-8");
        assert_eq!(&output, "1\n2\n3\n");
    }
}

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()
}

fn main() {
	mylib::RuntimeMod::set(998244353);
	let (r, w) = (std::io::stdin(), std::io::stdout());
	let mut sc = IO::new(r.lock(), w.lock());
	let b: usize = sc.read();
	let w: usize = sc.read();

	let n = b + w;
	let mut fact = vec![modint(1); n];
	for i in 1..n {
		fact[i] = fact[i-1] * modint(i);
	}
	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);
		}
	}

}