#include #include #include #include #include #include #include #include #include // #include template std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); } return os_arg; } template std::ostream& operator << (std::ostream& os_arg, const std::vector& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); } template std::ostream& operator << (std::ostream& os_arg, const std::array& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); } template std::ostream& operator << (std::ostream& os_arg, const std::pair& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; } #ifndef ONLINE_JUDGE template void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; } template void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); } #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false) #else #define dump(...) (void(0)) #endif long long int res[200]; int highestbit(long long int x){ return 63 - __builtin_clzll(x); } int len = 0; void push_integer(const long long int x){ res[len++] = x; } void out(void){ std::cout << len << '\n'; for(int i = 0; ; ){ std::cout << res[i]; ++i; if(i == len){ std::cout << '\n'; break; } else std::cout << ' '; } len = 0; } void solve(void){ long long int a, b; std::cin >> a >> b; while(2 * a > b){ const int bit = highestbit(a); a -= (1LL << bit); b -= (1LL << bit); } const int bit = highestbit(b); for(int i = 0; i < bit; ++i) if((a >> i) & 1){ a += (1LL << i); push_integer(1LL << i); } b ^= (1LL << bit); for(int i = bit - 1; i >= 0; --i) if((b >> i) & 1) push_integer(1LL << i); out(); } int main(void){ std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(16); int Q; std::cin >> Q; while(Q--) solve(); return 0; }