fn main() { let mut t = String::new(); std::io::stdin().read_line(&mut t).ok(); let t: usize = t.trim().parse().unwrap(); let queries = (0..t).map(|_| { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp: Vec = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); (temp[0], temp[1]) }) .collect::>(); for &(a, b) in queries.iter() { let bstr = format!("{:b}", b).chars().collect::>(); let astr = format!("{:b}", a); let astr = format!("{}{}", "0".repeat(bstr.len()-astr.len()), astr).chars().collect::>(); let n = bstr.len(); let start = (0..n).filter(|&i| bstr[i] != astr[i]).nth(0).unwrap(); let mut result = vec![]; let mut aval = a; for i in (start+1..n).rev() { let idx = n - 1 - i; if (aval >> idx) & 1 == 1 { result.push(1usize << idx); aval += 1usize << idx; } } for i in 0..n { let idx = n - 1 - i; if ((aval >> idx) & 1) != ((b >> idx) & 1) { result.push(1usize << idx); aval += 1usize << idx; } } println!("{}", result.len()); println!("{}", result.iter().map(|v| v.to_string()).collect::>().join(" ")); } }