#[allow(unused_macros)] macro_rules! read_line_to_tuple { ( $( $t:ty ),* ) => {{ let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); let mut iter = input.split_whitespace(); ( $( iter.next().unwrap().parse::<$t>().unwrap() ),* ) }}; } #[allow(unused_macros)] macro_rules! read_line_to_collection { ( $t:ty ) => {{ let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); let iter = input.split_whitespace(); iter.map(|x| x.parse().unwrap()).collect::<$t>() }}; } fn solve() -> String { let (mut a, b) = read_line_to_tuple!(i64, i64); let mut ans = Vec::new(); let mut p = 1; while a != b { while a % (p << 1) == 0 && a + (p << 1) <= b { p <<= 1; } while a + p > b { p >>= 1; } a += p; ans.push(p.to_string()); } format!("{}\n{}", ans.len(), ans.join(" ")) } fn main() { let t = read_line_to_tuple!(usize); let answers = (0..t).map(|_| solve()).collect::>(); println!("{}", answers.join("\n")); }