// -*- coding:utf-8-unix -*- #![allow(dead_code)] #![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::fs::File; use std::io::prelude::*; use std::io::*; use std::mem; use std::str; use std::vec; const INF: i64 = 1223372036854775807; const MEM_SIZE: usize = 202020; const MOD: i64 = 1000000007; // const MOD: i64 = 998244353; use std::cmp::*; use std::collections::*; use std::io::stdin; use std::io::stdout; use std::io::Write; #[allow(dead_code)] fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } #[allow(dead_code)] fn readi() -> (i64) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); iter.next().unwrap().parse::().unwrap() } #[allow(dead_code)] fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } #[allow(dead_code)] fn read_vec2(n: u32) -> Vec> { (0..n).map(|_| read_vec()).collect() } #[allow(dead_code)] fn readii() -> (i64, i64) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::().unwrap(), iter.next().unwrap().parse::().unwrap(), ) } #[allow(dead_code)] fn readiii() -> (i64, i64, i64) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::().unwrap(), iter.next().unwrap().parse::().unwrap(), iter.next().unwrap().parse::().unwrap(), ) } #[allow(dead_code)] fn readuu() -> (usize, usize) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::().unwrap(), iter.next().unwrap().parse::().unwrap(), ) } #[allow(dead_code)] fn readuuu() -> (usize, usize, usize) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::().unwrap(), iter.next().unwrap().parse::().unwrap(), iter.next().unwrap().parse::().unwrap(), ) } #[allow(dead_code)] fn readuuuu() -> (usize, usize, usize, usize) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::().unwrap(), iter.next().unwrap().parse::().unwrap(), iter.next().unwrap().parse::().unwrap(), iter.next().unwrap().parse::().unwrap(), ) } /// Equivalent to std::lowerbound and std::upperbound in c++ macro_rules! mint { (a :expr ) => { Mint::new({ a }) }; } #[derive(Copy, Clone)] pub struct Mint(i64); impl Mint { fn new(x: i64) -> Self { Mint(x.rem_euclid(MOD)) } fn pow(self, n: usize) -> Self { match n { 0 => Mint::new(1), _ => { let mut a = self.pow(n >> 1); a *= a; if n & 1 == 1 { a *= self; } a } } } fn inv(self) -> Self { self.pow((MOD - 2) as usize) } } impl std::ops::Neg for Mint { type Output = Mint; fn neg(self) -> Self::Output { Self::new(-self.0) } } impl std::ops::AddAssign for Mint { fn add_assign(&mut self, rhs: Self) { self.0 += rhs.0; self.0 %= MOD; } } impl std::ops::AddAssign for Mint { fn add_assign(&mut self, rhs: i64) { *self += Mint::new(rhs); } } impl std::ops::AddAssign for Mint { fn add_assign(&mut self, rhs: usize) { *self += Mint::new(rhs as i64); } } impl std::ops::Add for Mint where Mint: std::ops::AddAssign, { type Output = Self; fn add(self, other: T) -> Self { let mut res = self; res += other; res } } impl std::ops::SubAssign for Mint { fn sub_assign(&mut self, rhs: Self) { self.0 -= rhs.0; if self.0 < 0 { self.0 += MOD; } } } impl std::ops::SubAssign for Mint { fn sub_assign(&mut self, rhs: i64) { *self -= Mint::new(rhs); } } impl std::ops::SubAssign for Mint { fn sub_assign(&mut self, rhs: usize) { *self -= Mint::new(rhs as i64); } } impl std::ops::Sub for Mint where Mint: std::ops::SubAssign, { type Output = Self; fn sub(self, other: T) -> Self { let mut res = self; res -= other; res } } impl std::ops::MulAssign for Mint { fn mul_assign(&mut self, rhs: Self) { self.0 *= rhs.0; self.0 %= MOD; } } impl std::ops::MulAssign for Mint { fn mul_assign(&mut self, rhs: i64) { *self *= Mint::new(rhs); } } impl std::ops::MulAssign for Mint { fn mul_assign(&mut self, rhs: usize) { *self *= Mint::new(rhs as i64); } } impl std::ops::Mul for Mint where Mint: std::ops::MulAssign, { type Output = Self; fn mul(self, other: T) -> Self { let mut res = self; res *= other; res } } impl std::ops::DivAssign for Mint { fn div_assign(&mut self, rhs: Self) { *self *= rhs.inv(); } } impl std::ops::DivAssign for Mint { fn div_assign(&mut self, rhs: i64) { *self /= Mint::new(rhs); } } impl std::ops::DivAssign for Mint { fn div_assign(&mut self, rhs: usize) { *self /= Mint::new(rhs as i64); } } impl std::ops::Div for Mint where Mint: std::ops::DivAssign, { type Output = Self; fn div(self, other: T) -> Self { let mut res = self; res /= other; res } } impl std::fmt::Display for Mint { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.0) } } impl std::ops::Deref for Mint { type Target = i64; fn deref(&self) -> &Self::Target { &self.0 } } impl std::ops::DerefMut for Mint { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } #[allow(dead_code)] pub fn gcd(a: usize, b: usize) -> usize { if b == 0 { a } else { gcd(b, a % b) } } #[allow(dead_code)] pub fn lcm(a: usize, b: usize) -> usize { a / gcd(a, b) * b } #[allow(dead_code)] /// (gcd, x, y) pub fn extgcd(a: i64, b: i64) -> (i64, i64, i64) { if b == 0 { (a, 1, 0) } else { let (gcd, x, y) = extgcd(b, a % b); (gcd, y, x - (a / b) * y) } } #[allow(dead_code)] /// x ^ n % m pub fn mod_pow(x: usize, n: usize, m: usize) -> usize { let mut res = 1; let mut x = x % m; let mut n = n; while n > 0 { if n & 1 == 1 { res = (res * x) % m; } x = (x * x) % m; n >>= 1; } res } #[allow(dead_code)] pub fn mod_inverse(a: usize, m: usize) -> usize { let (_, x, _) = extgcd(a as i64, m as i64); ((m as i64 + x) as usize % m) % m } #[allow(dead_code)] pub fn fact_table(len: usize, m: usize) -> Vec { let mut res = vec![1; len + 1]; for i in 1..len + 1 { res[i] = (i as usize * res[i - 1]) % m; } res } #[allow(dead_code)] /// Factorial and Inverse factorial table pub fn fact_inv_table(size: usize, m: usize) -> (Vec, Vec) { let mut fact = vec![1; size]; let mut fact_inv = vec![1; size]; for i in 2..size { fact[i] = fact[i - 1] * i as usize % m; fact_inv[i] = m - ((m / i as usize) * fact_inv[(m % i as usize) as usize] % m); } for i in 1..size { fact_inv[i] = fact_inv[i - 1] * fact_inv[i] % m; } (fact, fact_inv) } #[allow(dead_code)] /// (a mod p, e when n! = a p\^e) pub fn mod_fact(n: usize, p: usize, fact: &[usize]) -> (usize, usize) { if n == 0 { (1, 0) } else { let (a, b) = mod_fact(n / p, p, fact); let pow = b + n / p; if n / p % 2 != 0 { (a * (p - fact[(n % p) as usize]) % p, pow) } else { (a * fact[(n % p) as usize] % p, pow) } } } #[allow(dead_code)] /// C(n, k) % p pub fn mod_comb(n: usize, k: usize, p: usize, fact: &[usize]) -> usize { if n < k { 0 } else { let (a1, e1) = mod_fact(n, p, fact); let (a2, e2) = mod_fact(k, p, fact); let (a3, e3) = mod_fact(n - k, p, fact); if e1 > e2 + e3 { 0 } else { a1 * mod_inverse(a2 * a3 % p, p) % p } } } pub fn mod_perm(n: usize, k: usize, p: usize, fact: &[usize]) -> usize { if n < k { 0 } else { let (a1, e1) = mod_fact(n, p, fact); let (a2, e2) = mod_fact(k, p, fact); let (a3, e3) = mod_fact(n - k, p, fact); if e1 > e2 + e3 { 0 } else { a1 % p } } } #[allow(dead_code)] /// H(n, k) % p pub fn mod_comb_repetition(n: usize, k: usize, p: usize, fact: &[usize]) -> usize { mod_comb(n - 1 + k, n - 1, p, fact) } fn solve() { let n: usize = read(); for i in 0..n { let mut res = vec![0; 0]; let (a, b) = readuu(); let mut p = a; for i in 1..60 { let mut x: usize = 1 << i; if (p % (x << 1) == x && p + x <= b) { p += x; res.push(x); // println!("{:?}", p); } } let mut q = b; for i in 0..60 { let mut x: usize = 1 << i; if (q % (x << 1) == x && p + x <= b) { q -= x; p += x; res.push(x); // println!("{:?}", p); } } // println!("{:?}", p); println!("{:?}", res.len()); for i in 0..res.len() { if (i != 0) { print!(" "); } print!("{}", res[i]) } println!(""); } return; } fn main() { solve() }