import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
q = int(input())
ans = []
pow2 = [1]
for _ in range(52):
pow2.append(2 * pow2[-1])
for _ in range(q):
a, b, m = map(int, input().split())
if a == b:
ans0 = [1, a]
ans.append(" ".join(map(str, ans0)))
continue
l, r = a, a
sl, sr = a, a
ok = 1
x = [a]
for i in range(2, 51):
l = sl + 1
r = sr + m
sl += l
sr += r
x.append(l)
if l <= b <= r:
k = i
break
elif b < l:
ok = 0
break
if not ok:
ans0 = "-1"
ans.append(ans0)
continue
for i in range(1, k - 1):
u = min(m - 1, (b - x[-1]) // pow2[k - i - 2])
x[i] += u
for j in range(i + 1, k):
x[j] += u
u *= 2
x[-1] = b
ans0 = [k] + x
ans.append(" ".join(map(str, ans0)))
sys.stdout.write("\n".join(ans))
/*
Problem: 1166D
Date: 17-02-2024 04:45 AM
*/
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < n; i++)
#define FORK(i, k, n) for(int i = k; i < n; i++)
#define FORr(i, n) for(int i = n - 1; i >= 0; i--)
#define FORKr(i, k, n) for(int i = n - 1; i >= k; i--)
#define PRINT(a, b) copy((a), (b), ostream_iterator<int>(cout, " "))
#define all(a) a.begin(), a.end()
#define in(a, b) ((b).find(a) != (b).end())
#define sz(a) ((int) (a).size())
#define Mp make_pair
#define PII pair<int, int>
#define LL long long
#define VI vector<int>
using namespace std;
LL a, b, m;
int main() {
std::ios_base::sync_with_stdio(false);
int q;
cin >> q;
while(q--) {
cin >> a >> b >> m;
LL p = 1;
if(a == b) {
cout << "1 " << a << endl;
continue;
}
FORK(n, 1, 50) {
if(b < p * (a + 1)) break;
if(p * (a + 1) <= b && b <= p * (a + m)) {
cout << (n + 1) << " " << a << " ";
vector<int> r(n);
LL R = b / p - a;
// cout << "R: " << R << ", ";
r[n - 1] = 0;
FOR(i, n - 1) {
r[n - i - 2] = ((b % p) >> i) & 1;
// cout << +r[n - i - 1] << " ";
}
LL term = a;
LL sum = a;
FOR(i, n) {
term = sum + R + r[i];
sum += term;
cout << term << " ";
}
goto outer;
}
p *= 2;
}
cout << -1;
outer:
cout << endl;
}
}
1234A - Equalize Prices Again | 1613A - Long Comparison |
1624B - Make AP | 660B - Seating On Bus |
405A - Gravity Flip | 499B - Lecture |
709A - Juicer | 1358C - Celex Update |
1466B - Last minute enhancements | 450B - Jzzhu and Sequences |
1582C - Grandma Capa Knits a Scarf | 492A - Vanya and Cubes |
217A - Ice Skating | 270A - Fancy Fence |
181A - Series of Crimes | 1638A - Reverse |
1654C - Alice and the Cake | 369A - Valera and Plates |
1626A - Equidistant Letters | 977D - Divide by three multiply by two |
1654B - Prefix Removals | 1654A - Maximum Cake Tastiness |
1649A - Game | 139A - Petr and Book |
1612A - Distance | 520A - Pangram |
124A - The number of positions | 1041A - Heist |
901A - Hashing Trees | 1283A - Minutes Before the New Year |