#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let t = read::(); for _ in 0..t { let v = read_vec::(); let (mut a, b) = (v[0], v[1]); let mut cur = 1; loop { if a % cur != 0 { cur /= 2; break; } cur *= 2; } let mut answers = vec![]; while a + cur <= b { a += cur; answers.push(cur); while a % cur == 0 && a + cur <= b { cur *= 2; } cur /= 2; } while a < b { if a + cur > b { cur /= 2; } else { a += cur; answers.push(cur); cur /= 2; } } println!("{}", answers.len()); for &ans in answers.iter().take(answers.len() - 1) { print!("{} ", ans); } println!("{}", answers[answers.len() - 1]); } } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }