#include <cstdio>
#include <algorithm>
#include <vector>

typedef long long LL;
const LL Infll = 0x3f3f3f3f3f3f3f3f;
const int MN = 100005, MS = 1 << 18 | 7;

LL K, W[MN], G[MN], pre[MN], suf[MN];
int N, nxt[MN], Ans;
std::vector<int> T[MN];

#define li (i << 1)
#define ri (li | 1)
#define mid ((l + r) >> 1)
#define ls li, l, mid
#define rs ri, mid + 1, r
LL amn[MS], bmn[MS], ans[MS], tg[MS];
inline void P(int i, LL x) { bmn[i] += x, ans[i] -= x, tg[i] += x; }
inline void Pushdown(int i) { if (tg[i]) P(li, tg[i]), P(ri, tg[i]), tg[i] = 0; }
LL Calc(int i, int l, int r, LL p) {
	if (l == r) return amn[i] - p;
	Pushdown(i);
	if (bmn[li] < p) return std::min(Calc(ls, p), ans[i]);
	else return std::min(amn[li] - p, Calc(rs, p));
}
void Build(int i, int l, int r) {
	if (l == r) { amn[i] = bmn[i] = suf[l]; return ; }
	Build(ls), Build(rs);
	amn[i] = std::min(amn[li], amn[ri]);
	bmn[i] = std::min(bmn[li], bmn[ri]);
	ans[i] = Calc(rs, bmn[li]);
}
void Mdf(int i, int l, int r, int a, int b, LL x) {
	if (r < a || b < l) return ;
	if (a <= l && r <= b) return P(i, x);
	Pushdown(i), Mdf(ls, a, b, x), Mdf(rs, a, b, x);
	bmn[i] = std::min(bmn[li], bmn[ri]);
	ans[i] = Calc(rs, bmn[li]);
}
int Solve2(int i, int l, int r, LL v) {
	if (l == r) return l;
	return amn[ri] <= v ? Solve2(rs, v) : Solve2(ls, v);
}
int Solve(int i, int l, int r, LL &p) {
	if (l == r) {
		int ret = amn[i] - p <= K ? l : 0;
		p = std::min(p, bmn[i]);
		return ret;
	}
	Pushdown(i);
	if (bmn[li] < p) {
		if (ans[i] <= K) return Solve(rs, p = bmn[li]);
		else {
			int ret = Solve(ls, p);
			p = std::min(p, bmn[i]);
			return ret;
		}
	} else {
		int ret = amn[li] <= K + p ? Solve2(ls, K + p) : 0;
		return std::max(ret, Solve(rs, p));
	}
}
#undef li
#undef ri
#undef mid
#undef ls
#undef rs

inline void DFS(int u) {
	static int stk[MN], tp;
	stk[++tp] = u;
	if (nxt[u] <= N) Mdf(1, 1, N, nxt[u] - 1, N, pre[u] - pre[nxt[u]]);
	if (u <= N) {
		int lb = 2, rb = tp - 1, mid, ret = 1;
		while (lb <= rb) {
			mid = (lb + rb) >> 1;
			if (pre[stk[mid]] - pre[u] > K) ret = mid, lb = mid + 1;
			else rb = mid - 1;
		}
		int rmax = stk[ret] - 1; LL _ = Infll;
		if (u > 1) Mdf(1, 1, N, 1, u - 1, Infll);
		Mdf(1, 1, N, rmax, N, -Infll);
		int pos = Solve(1, 1, N, _);
		Mdf(1, 1, N, rmax, N, Infll);
		if (u > 1) Mdf(1, 1, N, 1, u - 1, -Infll);
		Ans = std::max(Ans, pos - u + 1);
	}
	for (auto v : T[u]) DFS(v);
	if (nxt[u] <= N) Mdf(1, 1, N, nxt[u] - 1, N, pre[nxt[u]] - pre[u]);
	--tp;
}

inline void Init() {
	static int stk[MN], tp;
	scanf("%d%lld", &N, &K), Ans = 1;
	for (int i = 1; i < N; ++i) scanf("%lld", &W[i]);
	for (int i = 1; i <= N; ++i) scanf("%lld", &G[i]);
	for (int i = 2; i <= N; ++i)
		pre[i] = pre[i - 1] - G[i - 1] + W[i - 1],
		suf[i] = suf[i - 1] - G[i] + W[i - 1];
	pre[N + 1] = Infll, nxt[N + 1] = stk[tp = 1] = N + 1;
	for (int i = N; i >= 1; --i) {
		while (pre[stk[tp]] <= pre[i]) --tp;
		nxt[i] = stk[tp], stk[++tp] = i;
		T[nxt[i]].push_back(i);
	}
}

int main() {
	Init();
	Build(1, 1, N);
	DFS(N + 1);
	printf("%d\n", Ans);
	return 0;
}

// Luogu : PinkRabbit


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define int long long
using namespace std;
const int maxn = 2e5+10;
const int inf = 1e18;

int read(){
    int x=0,f=1;
    char c=getchar();
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
    return x*f;
}

int k,m,n;
int a[maxn],b[maxn],f[maxn],g[maxn];
int s[maxn],top=0;
int lazy[maxn<<2],min1[maxn<<2],min2[maxn<<2];
void build(int k,int l,int r,int x){
    if(l==r){min1[k]=min2[k]=g[l];return;}
    int mid=(l+r)>>1;
    if(mid>=x)build(k<<1,l,mid,x);
    else build(k<<1|1,mid+1,r,x);
    min1[k]=min(min1[k<<1],min1[k<<1|1]);
    min2[k]=min(min2[k<<1],min2[k<<1|1]);
    return;
}

void pushdown(int k,int l,int r){
    if(lazy[k]!=0){
        int mid=(l+r)>>1;
        lazy[k<<1]+=lazy[k];
        lazy[k<<1|1]+=lazy[k];
        min1[k<<1]+=lazy[k];
        min1[k<<1|1]+=lazy[k];
        lazy[k]=0;
    }
    return;
}

void modify(int k,int l,int r,int ls,int rs,int x){
    if(ls<=l && r<=rs){
        min1[k]+=x;
        lazy[k]+=x;
        return;
    }
    pushdown(k,l,r);
    int mid=(l+r)>>1;
    if(mid>=ls)modify(k<<1,l,mid,ls,rs,x);
    if(mid+1<=rs)modify(k<<1|1,mid+1,r,ls,rs,x);
    min1[k]=min(min1[k<<1],min1[k<<1|1]);
    return;
}

int query(int h,int l,int r,int s,int x){
    //cerr<<h<<" "<<l<<" "<<r<<" "<<s<<" "<<x<<endl;
    if(x<l)return 0;
    if(l==r)return l;
    pushdown(h,l,r);
    int mid=(l+r)>>1;
    if(min(s,min1[h<<1])>=min2[h<<1|1]-k){
        //cerr<<min(s,min1[h<<1])<<endl;
        int y=query(h<<1|1,mid+1,r,min(s,min1[h<<1]),x);
        if(y)return y;
    }
    if(min2[h]-k<=s)return query(h<<1,l,mid,s,x);
    return 0;
}

signed main(){
    n=read();k=read();
    for(register int i=1;i<n;i++)a[i]=read();
    for(register int i=1;i<=n;i++)b[i]=read();
    for(register int i=1;i<=n;i++)f[i]=f[i-1]-a[i-1]+b[i-1];
    for(register int i=1;i<=n;i++)g[i]=g[i-1]-b[i]+a[i-1];
    int ans=0;
    s[0]=n+1;
    memset(min1,0x3f,sizeof(min1));
    memset(min2,-0x3f,sizeof(min2));
    for(register int l=n;l>=1;l--){
        build(1,1,n,l);
        while(top && f[s[top]]>=f[l]){
            if(top>1)modify(1,1,n,s[top-1]-1,n,f[s[top]]-f[s[top-1]]);
            top--;
        }
        s[++top]=l;
        if(top>1)modify(1,1,n,s[top-1]-1,n,f[s[top-1]]-f[s[top]]);
        int L=1,R=top,mid,anss;
        while(L<=R){
            int mid=(L+R)>>1;
            if(f[l]-f[s[mid]]<=k)R=mid-1;
            else L=mid+1;
        }
        ans=max(ans,query(1,1,n,inf,s[R]-1)-l+1);
    }
    printf("%lld\n",ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N = 100005;
const ll inf = 1ll << 60;
int n, k, w[N], g[N], st[N], top;
ll cl[N], cr[N], add[N * 3], mna[N * 3], mnb[N * 3];

void pushup(int u) {
	mnb[u] = min(mnb[u << 1], mnb[u << 1 | 1]);
}
void build(int u, int l, int r) {
	mnb[u] = inf;
	if (l == r) {
		mna[u] = cr[l];
		return;
	}
	int mid = l + r >> 1;
	build(u << 1, l, mid);
	build(u << 1 | 1, mid + 1, r);
	mna[u] = min(mna[u << 1], mna[u << 1 | 1]);
	pushup(u);
}
void push(int u, ll v) {
	mnb[u] += v, add[u] += v;
}
void pushdown(int u) {
	if (add[u]) {
		push(u << 1, add[u]);
		push(u << 1 | 1, add[u]);
		add[u] = 0;
	}
}
void update(int u, int l, int r, int ql, int qr, ll v) {
	if (l >= ql && r <= qr) { push(u, v); return; }
	int mid = l + r >> 1;
	pushdown(u);
	if (ql <= mid) update(u << 1, l, mid, ql, qr, v);
	if (qr > mid) update(u << 1 | 1, mid + 1, r, ql, qr, v);
	pushup(u);
}
void update(int u, int l, int r, int pos) {
	if (l == r) {
		mnb[u] = cr[l];
		return;
	}
	int mid = l + r >> 1;
	pushdown(u);
	if (pos <= mid) update(u << 1, l, mid, pos);
	else update(u << 1 | 1, mid + 1, r, pos);
	pushup(u);
}
int query(int u, int l, int r, int ql, int qr, ll mn) {
	if (ql > qr || ql > r || qr < l) return 0;
	if (l == r) return l;
	int mid = l + r >> 1;
	pushdown(u);
	if (mna[u << 1 | 1] - min(mn, mnb[u << 1]) <= k) {
		int tmp = query(u << 1 | 1, mid + 1, r, ql, qr, min(mn, mnb[u << 1]));
		if (tmp) return tmp;
	}
	return query(u << 1, l, mid, ql, qr, mn);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i < n; ++i) cin >> w[i];
	for (int i = 1; i <= n; ++i) cin >> g[i];
	for (int i = 1; i <= n; ++i) cl[i] = cl[i - 1] + g[i - 1] - w[i - 1], cr[i] = cr[i - 1] - g[i] + w[i - 1];
	build(1, 1, n);
	int ans = 0;
	for (int i = n; i; --i) {
		update(1, 1, n, i);
		while (top && cl[i] <= cl[st[top]]) {
			if (top > 1) update(1, 1, n, st[top - 1] - 1, n, cl[st[top]] - cl[st[top - 1]]);
			--top;
		}
		st[++top] = i;
		if (top > 1) update(1, 1, n, st[top - 1] - 1, n, cl[st[top - 1]] - cl[i]);
		int l = 1, r = top;
		while (l < r) {
			int mid = l + r >> 1;
			if (cl[i] - cl[st[mid]] <= k) r = mid;
			else l = mid + 1;
		}
		ans = max(ans, query(1, 1, n, i, (r == 1 ? n : st[r - 1] - 1), inf) - i + 1);
	}
	cout << ans << endl;
}


#include<bits/stdc++.h>
#define ll long long
#define lld long double
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 101000;
int st[N],top,n,w[N],g[N],nxt[N];
ll pre[N],suf[N],K,ans;
vector<int> e[N];
struct segment_tree{
	ll ms[N*4],mp[N*4],h[N*4],tag[N*4];
	void add(int x,ll k){
		ms[x]+=k;
		tag[x]+=k;
		h[x]+=k;
	}
	void pushdown(int x){
		if(!tag[x]) return;
		add(x<<1,tag[x]);
		add(x<<1|1,tag[x]);
		tag[x]=0;
	}
	ll calc(int x,int l,int r,ll k){
		if(l==r) return k+mp[x];
		pushdown(x);
		int mid=l+r>>1;
		if(k<=ms[x<<1]) return min(h[x],calc(x<<1,l,mid,k));
		else return min(k+mp[x],calc(x<<1|1,mid+1,r,k));
	}
	void pushup(int x,int l,int r){
		ms[x]=max(ms[x<<1],ms[x<<1|1]);
		int mid=l+r>>1;
		h[x]=calc(x<<1|1,mid+1,r,ms[x<<1]);
	}
	void build(int x=1,int l=1,int r=n){
		if(l==r){
			mp[x]=-suf[l];
			ms[x]=suf[l];
			return;
		}
		int mid=l+r>>1;
		build(x<<1,l,mid);
		build(x<<1|1,mid+1,r);
		mp[x]=min(mp[x<<1],mp[x<<1|1]);
		pushup(x,l,r);
	}
	void modify(int ql,int qr,ll k,int x=1,int l=1,int r=n){
		if(ql<=l&&qr>=r){
			add(x,k);return;
		}
		int mid=l+r>>1;
		pushdown(x);
		if(ql<=mid) modify(ql,qr,k,x<<1,l,mid);
		if(qr>mid) modify(ql,qr,k,x<<1|1,mid+1,r);
		pushup(x,l,r);
	}
	ll query(ll k=-1e17,int x=1,int l=1,int r=n){
		if(l==r) return k+mp[x]<=K?l:0;
		int mid=l+r>>1;
		pushdown(x);
		ll tmp=k<=ms[x<<1]?h[x]:calc(x<<1|1,mid+1,r,k);
		if(tmp<=K) return query(max(ms[x<<1],k),x<<1|1,mid+1,r);
		return query(k,x<<1,l,mid);
	}
}t;
void dfs(int x,int dad){
	st[++top]=x;
	if(dad){
		t.modify(dad-1,n,-pre[dad-1]+pre[x-1]);
		int l=1,r=top+1;
		while(l+1<r){
			int mid=l+r>>1;
			if(pre[x-1]-pre[st[mid]-1]<=K) r=mid;
			else l=mid;
		}
		if(x>1) t.modify(1,x-1,-1e17);
		if(st[l]<=n) t.modify(st[l],n,1e17);
		ans=max(ans,t.query()-x+1);
		if(x>1) t.modify(1,x-1,1e17);
		if(st[l]<=n) t.modify(st[l],n,-1e17);
	}
	for(int v:e[x]) if(v!=dad) dfs(v,x);
	if(dad) t.modify(dad-1,n,-pre[x-1]+pre[dad-1]);
}
int main(){
	read(n);read(K);
	for(int i=1;i<n;i++) read(w[i]);
	for(int i=1;i<=n;i++) read(g[i]);
	for(int i=1;i<=n;i++)
		pre[i]=pre[i-1]-w[i]+g[i],suf[i]=suf[i-1]-w[i-1]+g[i];
	t.build();
	for(int i=n;i;i--){
		nxt[i]=i;
		while(nxt[i]<n&&pre[nxt[i]]-pre[i-1]>=0) nxt[i]=nxt[nxt[i]+1];
		e[nxt[i]+1].push_back(i);
	}
	dfs(n+1,0);
	cout<<ans<<'\n';
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define lld long double
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 101000;
int st[N],top,n,w[N],g[N],nxt[N];
ll pre[N],suf[N],K,ans;
vector<int> e[N];
struct segment_tree{
	ll ms[N*4],mp[N*4],h[N*4],tag[N*4];
	void add(int x,ll k){
		ms[x]+=k;
		tag[x]+=k;
		h[x]+=k;
	}
	void pushdown(int x){
		if(!tag[x]) return;
		add(x<<1,tag[x]);
		add(x<<1|1,tag[x]);
		tag[x]=0;
	}
	ll calc(int x,int l,int r,ll k){
		if(l==r){
			return max(k,ms[x])+mp[x];
		}
		pushdown(x);
		int mid=l+r>>1;
		if(k<=ms[x<<1]) return min(h[x],calc(x<<1,l,mid,k));
		else return min(k+mp[x],calc(x<<1|1,mid+1,r,k));
	}
	void pushup(int x,int l,int r){
		ms[x]=max(ms[x<<1],ms[x<<1|1]);
		int mid=l+r>>1;
		h[x]=calc(x<<1|1,mid+1,r,ms[x<<1]);
	}
	void build(int x=1,int l=1,int r=n){
		if(l==r){
			mp[x]=-suf[l];
			ms[x]=suf[l];
			return;
		}
		int mid=l+r>>1;
		build(x<<1,l,mid);
		build(x<<1|1,mid+1,r);
		mp[x]=min(mp[x<<1],mp[x<<1|1]);
		pushup(x,l,r);
	}
	void modify(int ql,int qr,ll k,int x=1,int l=1,int r=n){
		if(ql<=l&&qr>=r){
			add(x,k);return;
		}
		int mid=l+r>>1;
		pushdown(x);
		if(ql<=mid) modify(ql,qr,k,x<<1,l,mid);
		if(qr>mid) modify(ql,qr,k,x<<1|1,mid+1,r);
		pushup(x,l,r);
	}
	ll query(ll k=-1e17,int x=1,int l=1,int r=n){
		if(l==r) return max(k,ms[x])+mp[x]<=K?l:0;
		int mid=l+r>>1;
		pushdown(x);
		ll tmp=k<=ms[x<<1]?h[x]:calc(x<<1|1,mid+1,r,k);
		if(tmp<=K) return query(max(ms[x<<1],k),x<<1|1,mid+1,r);
		return query(k,x<<1,l,mid);
	}
}t;
void dfs(int x,int dad){
	st[++top]=x;
	if(dad){
		if(dad<=n) t.modify(dad,n,-pre[dad-1]+pre[x-1]);
		int l=1,r=top+1;
		while(l+1<r){
			int mid=l+r>>1;
			if(pre[x-1]-pre[st[mid]-1]<=K) r=mid;
			else l=mid;
		}
		if(x>1) t.modify(1,x-1,-1e17);
		if(st[l]<=n) t.modify(st[l],n,1e17);
		ans=max(ans,t.query()-x+1);
		if(x>1) t.modify(1,x-1,1e17);
		if(st[l]<=n) t.modify(st[l],n,-1e17);
	}
	for(int v:e[x]) if(v!=dad) dfs(v,x);
	if(dad<=n) t.modify(dad,n,-pre[x-1]+pre[dad-1]);
	top--;
}
int main(){
	read(n);read(K);
	for(int i=1;i<n;i++) read(w[i]);
	for(int i=1;i<=n;i++) read(g[i]);
	for(int i=1;i<=n;i++)
		pre[i]=pre[i-1]-w[i]+g[i],suf[i]=suf[i-1]-w[i-1]+g[i];
	t.build();
	for(int i=n;i;i--){
		nxt[i]=i;
		while(nxt[i]<n&&pre[nxt[i]]-pre[i-1]>=0) nxt[i]=nxt[nxt[i]+1];
		e[nxt[i]+1].push_back(i);
	}
	dfs(n+1,0);
	cout<<ans<<'\n';
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define lld long double
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 101000;
int st[N],top,n,w[N],g[N],nxt[N];
ll pre[N],suf[N],K,ans;
vector<int> e[N];
struct segment_tree{
	ll ms[N*4],mp[N*4],h[N*4],tag[N*4];
	void add(int x,ll k){
		ms[x]+=k;
		tag[x]+=k;
		h[x]+=k;
	}
	void pushdown(int x){
		if(!tag[x]) return;
		add(x<<1,tag[x]);
		add(x<<1|1,tag[x]);
		tag[x]=0;
	}
	ll calc(int x,int l,int r,ll k){
		if(l==r) return k+mp[x];
		pushdown(x);
		int mid=l+r>>1;
		if(k<=ms[x<<1]) return min(h[x],calc(x<<1,l,mid,k));
		else return min(k+mp[x],calc(x<<1|1,mid+1,r,k));
	}
	void pushup(int x,int l,int r){
		ms[x]=max(ms[x<<1],ms[x<<1|1]);
		int mid=l+r>>1;
		h[x]=calc(x<<1|1,mid+1,r,ms[x<<1]);
	}
	void build(int x=1,int l=1,int r=n){
		if(l==r){
			mp[x]=-suf[l];
			ms[x]=suf[l];
			return;
		}
		int mid=l+r>>1;
		build(x<<1,l,mid);
		build(x<<1|1,mid+1,r);
		mp[x]=min(mp[x<<1],mp[x<<1|1]);
		pushup(x,l,r);
	}
	void modify(int ql,int qr,ll k,int x=1,int l=1,int r=n){
		if(ql<=l&&qr>=r){
			add(x,k);return;
		}
		int mid=l+r>>1;
		pushdown(x);
		if(ql<=mid) modify(ql,qr,k,x<<1,l,mid);
		if(qr>mid) modify(ql,qr,k,x<<1|1,mid+1,r);
		pushup(x,l,r);
	}
	ll query(ll k=-1e17,int x=1,int l=1,int r=n){
		if(l==r) return k+mp[x]<=K?l:0;
		int mid=l+r>>1;
		pushdown(x);
		ll tmp=k<=ms[x<<1]?h[x]:calc(x<<1|1,mid+1,r,k);
		if(tmp<=K) return query(max(ms[x<<1],k),x<<1|1,mid+1,r);
		return query(k,x<<1,l,mid);
	}
}t;
void dfs(int x,int dad){
	st[++top]=x;
	if(dad){
		t.modify(dad-1,n,-pre[dad-1]+pre[x-1]);
		int l=1,r=top+1;
		while(l+1<r){
			int mid=l+r>>1;
			if(pre[x-1]-pre[st[mid]-1]<=K) r=mid;
			else l=mid;
		}
		if(x>1) t.modify(1,x-1,-1e17);
		if(st[l]<=n) t.modify(st[l],n,1e17);
		ans=max(ans,t.query()-x+1);
		if(x>1) t.modify(1,x-1,1e17);
		if(st[l]<=n) t.modify(st[l],n,-1e17);
	}
	for(int v:e[x]) if(v!=dad) dfs(v,x);
	if(dad) t.modify(dad-1,n,-pre[x-1]+pre[dad-1]);
	top--;
}
int main(){
	read(n);read(K);
	for(int i=1;i<n;i++) read(w[i]);
	for(int i=1;i<=n;i++) read(g[i]);
	for(int i=1;i<=n;i++)
		pre[i]=pre[i-1]-w[i]+g[i],suf[i]=suf[i-1]-w[i-1]+g[i];
	t.build();
	for(int i=n;i;i--){
		nxt[i]=i;
		while(nxt[i]<n&&pre[nxt[i]]-pre[i-1]>=0) nxt[i]=nxt[nxt[i]+1];
		e[nxt[i]+1].push_back(i);
	}
	dfs(n+1,0);
	cout<<ans<<'\n';
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define lld long double
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 101000;
int st[N],top,n,w[N],g[N],nxt[N];
ll pre[N],suf[N],K,ans;
vector<int> e[N];
struct segment_tree{
	ll ms[N*4],mp[N*4],h[N*4],tag[N*4];
	void add(int x,ll k){
		ms[x]+=k;
		tag[x]+=k;
		h[x]+=k;
	}
	void pushdown(int x){
		if(!tag[x]) return;
		add(x<<1,tag[x]);
		add(x<<1|1,tag[x]);
		tag[x]=0;
	}
	ll calc(int x,int l,int r,ll k){
		if(l==r) return max(k,ms[x])+mp[x];
		pushdown(x);
		int mid=l+r>>1;
		if(k<=ms[x<<1]) return min(h[x],calc(x<<1,l,mid,k));
		else return min(k+mp[x],calc(x<<1|1,mid+1,r,k));
	}
	void pushup(int x,int l,int r){
		ms[x]=max(ms[x<<1],ms[x<<1|1]);
		int mid=l+r>>1;
		h[x]=calc(x<<1|1,mid+1,r,ms[x<<1]);
	}
	void build(int x=1,int l=1,int r=n){
		if(l==r){
			mp[x]=-suf[l];
			ms[x]=suf[l];
			return;
		}
		int mid=l+r>>1;
		build(x<<1,l,mid);
		build(x<<1|1,mid+1,r);
		mp[x]=min(mp[x<<1],mp[x<<1|1]);
		pushup(x,l,r);
	}
	void modify(int ql,int qr,ll k,int x=1,int l=1,int r=n){
		if(ql<=l&&qr>=r){
			add(x,k);return;
		}
		int mid=l+r>>1;
		pushdown(x);
		if(ql<=mid) modify(ql,qr,k,x<<1,l,mid);
		if(qr>mid) modify(ql,qr,k,x<<1|1,mid+1,r);
		pushup(x,l,r);
	}
	ll query(ll k=-1e17,int x=1,int l=1,int r=n){
		if(l==r) return max(k,ms[x])+mp[x]<=K?l:0;
		int mid=l+r>>1;
		pushdown(x);
		ll tmp=k<=ms[x<<1]?h[x]:calc(x<<1|1,mid+1,r,k);
		if(tmp<=K) return query(max(ms[x<<1],k),x<<1|1,mid+1,r);
		return query(k,x<<1,l,mid);
	}
}t;
void dfs(int x,int dad){
	st[++top]=x;
	if(dad){
		t.modify(dad-1,n,-pre[dad-1]+pre[x-1]);
		int l=1,r=top+1;
		while(l+1<r){
			int mid=l+r>>1;
			if(pre[x-1]-pre[st[mid]-1]<=K) r=mid;
			else l=mid;
		}
		if(x>1) t.modify(1,x-1,-1e17);
		if(st[l]<=n) t.modify(st[l],n,1e17);
		ans=max(ans,t.query()-x+1);
		if(x>1) t.modify(1,x-1,1e17);
		if(st[l]<=n) t.modify(st[l],n,-1e17);
	}
	for(int v:e[x]) if(v!=dad) dfs(v,x);
	if(dad) t.modify(dad-1,n,-pre[x-1]+pre[dad-1]);
}
int main(){
	read(n);read(K);
	for(int i=1;i<n;i++) read(w[i]);
	for(int i=1;i<=n;i++) read(g[i]);
	for(int i=1;i<=n;i++)
		pre[i]=pre[i-1]-w[i]+g[i],suf[i]=suf[i-1]-w[i-1]+g[i];
	t.build();
	for(int i=n;i;i--){
		nxt[i]=i;
		while(nxt[i]<n&&pre[nxt[i]]-pre[i-1]>=0) nxt[i]=nxt[nxt[i]+1];
		e[nxt[i]+1].push_back(i);
	}
	dfs(n+1,0);
	cout<<ans<<'\n';
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define lld long double
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 101000;
int st[N],top,n,w[N],g[N],nxt[N];
ll pre[N],suf[N],K,ans;
vector<int> e[N];
struct segment_tree{
	ll ms[N*4],mp[N*4],h[N*4],tag[N*4];
	void add(int x,ll k){
		ms[x]+=k;
		tag[x]+=k;
		h[x]+=k;
	}
	void pushdown(int x){
		if(!tag[x]) return;
		add(x<<1,tag[x]);
		add(x<<1|1,tag[x]);
		tag[x]=0;
	}
	ll calc(int x,int l,int r,ll k){
		if(l==r){
			return max(k,ms[x])+mp[x];
		}
		pushdown(x);
		int mid=l+r>>1;
		if(k<=ms[x<<1]) return min(h[x],calc(x<<1,l,mid,k));
		else return min(k+mp[x],calc(x<<1|1,mid+1,r,k));
	}
	void pushup(int x,int l,int r){
		ms[x]=max(ms[x<<1],ms[x<<1|1]);
		int mid=l+r>>1;
		h[x]=calc(x<<1|1,mid+1,r,ms[x<<1]);
	}
	void build(int x=1,int l=1,int r=n){
		if(l==r){
			mp[x]=-suf[l];
			ms[x]=suf[l];
			return;
		}
		int mid=l+r>>1;
		build(x<<1,l,mid);
		build(x<<1|1,mid+1,r);
		mp[x]=min(mp[x<<1],mp[x<<1|1]);
		pushup(x,l,r);
	}
	void modify(int ql,int qr,ll k,int x=1,int l=1,int r=n){
		if(ql<=l&&qr>=r){
			add(x,k);return;
		}
		int mid=l+r>>1;
		pushdown(x);
		if(ql<=mid) modify(ql,qr,k,x<<1,l,mid);
		if(qr>mid) modify(ql,qr,k,x<<1|1,mid+1,r);
		pushup(x,l,r);
	}
	ll query(ll k=-1e17,int x=1,int l=1,int r=n){
		if(l==r) return max(k,ms[x])+mp[x]<=K?l:0;
		int mid=l+r>>1;
		pushdown(x);
		ll tmp=k<=ms[x<<1]?h[x]:calc(x<<1|1,mid+1,r,k);
		if(tmp<=K) return query(max(ms[x<<1],k),x<<1|1,mid+1,r);
		return query(k,x<<1,l,mid);
	}
}t;
void dfs(int x,int dad){
	st[++top]=x;
	if(dad){
		if(dad<=n) t.modify(dad,n,-pre[dad-1]+pre[x-1]);
		int l=1,r=top+1;
		while(l+1<r){
			int mid=l+r>>1;
			if(pre[x-1]-pre[st[mid]-1]<=K) r=mid;
			else l=mid;
		}
		if(x>1) t.modify(1,x-1,-1e17);
		if(st[l]<=n) t.modify(st[l],n,1e17);
		ans=max(ans,t.query()-x+1);
		if(x>1) t.modify(1,x-1,1e17);
		if(st[l]<=n) t.modify(st[l],n,-1e17);
	}
	for(int v:e[x]) if(v!=dad) dfs(v,x);
	if(dad<=n&&dad) t.modify(dad,n,-pre[x-1]+pre[dad-1]);
	top--;
}
int main(){
	read(n);read(K);
	for(int i=1;i<n;i++) read(w[i]);
	for(int i=1;i<=n;i++) read(g[i]);
	for(int i=1;i<=n;i++)
		pre[i]=pre[i-1]-w[i]+g[i],suf[i]=suf[i-1]-w[i-1]+g[i];
	t.build();
	for(int i=n;i;i--){
		nxt[i]=i;
		while(nxt[i]<n&&pre[nxt[i]]-pre[i-1]>=0) nxt[i]=nxt[nxt[i]+1];
		e[nxt[i]+1].push_back(i);
	}
	dfs(n+1,0);
	cout<<ans<<'\n';
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define lld long double
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 101000;
int st[N],top,n,w[N],g[N],nxt[N];
ll pre[N],suf[N],K,ans;
vector<int> e[N];
struct segment_tree{
	ll ms[N*4],mp[N*4],h[N*4],tag[N*4];
	void add(int x,ll k){
		ms[x]+=k;
		tag[x]+=k;
		h[x]+=k;
	}
	void pushdown(int x){
		if(!tag[x]) return;
		add(x<<1,tag[x]);
		add(x<<1|1,tag[x]);
		tag[x]=0;
	}
	ll calc(int x,int l,int r,ll k){
		if(l==r) return k+mp[x];
		int mid=l+r>>1;
		if(k<=ms[x<<1]) return min(h[x],calc(x<<1,l,mid,k));
		else return min(k+mp[x],calc(x<<1|1,mid+1,r,k));
	}
	void pushup(int x,int l,int r){
		ms[x]=max(ms[x<<1],ms[x<<1|1]);
		int mid=l+r>>1;
		h[x]=calc(x<<1|1,mid+1,r,ms[x<<1]);
	}
	void build(int x=1,int l=1,int r=n){
		if(l==r){
			mp[x]=-suf[l];
			ms[x]=suf[l];
			return;
		}
		int mid=l+r>>1;
		build(x<<1,l,mid);
		build(x<<1|1,mid+1,r);
	}
	void modify(int ql,int qr,ll k,int x=1,int l=1,int r=n){
		if(ql<=l&&qr>=r){
			add(x,k);return;
		}
		int mid=l+r>>1;
		pushdown(x);
		if(ql<=mid) modify(ql,qr,k,x<<1,l,mid);
		if(qr>mid) modify(ql,qr,k,x<<1|1,mid+1,r);
		pushup(x,l,r);
	}
	ll query(ll k=-1e17,int x=1,int l=1,int r=n){
		if(l==r) return k+mp[x]<=K?l:0;
		int mid=l+r>>1;
		pushdown(x);
		ll tmp=k<=ms[x<<1]?h[x]:calc(x<<1|1,mid+1,r,k);
		if(tmp<=K) return query(k,x<<1|1,mid+1,r);
		return query(k,x<<1,l,mid);
	}
}t;
void dfs(int x,int dad){
	st[++top]=x;
	if(dad){
		t.modify(dad-1,n,-pre[dad-1]+pre[x-1]);
		int l=1,r=top+1;
		while(l+1<r){
			int mid=l+r>>1;
			if(pre[x-1]-pre[st[mid]-1]<=K) r=mid;
			else l=mid;
		}
		if(x>1) t.modify(1,x-1,-1e17);
		if(st[l]<=n) t.modify(st[l],n,1e17);
		ans=max(ans,t.query()-x+1);
		if(x>1) t.modify(1,x-1,1e17);
		if(st[l]<=n) t.modify(st[l],n,-1e17);
	}
	for(int v:e[x]) if(v!=dad) dfs(v,x);
	if(dad) t.modify(dad-1,n,-pre[x-1]+pre[dad-1]);
}
int main(){
	read(n);read(K);
	for(int i=1;i<n;i++) read(w[i]);
	for(int i=1;i<=n;i++) read(g[i]);
	for(int i=1;i<=n;i++)
		pre[i]=pre[i-1]-w[i]+g[i],suf[i]=suf[i-1]-w[i-1]+g[i];
	t.build();
	for(int i=n;i;i--){
		nxt[i]=i;
		while(nxt[i]<n&&pre[nxt[i]]-pre[i-1]>=0) nxt[i]=nxt[nxt[i]+1];
		e[nxt[i]+1].push_back(i);
	}
	dfs(n+1,0);
	cout<<ans<<'\n';
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <vector>

typedef long long LL;
const LL Infll = 0x3f3f3f3f3f3f3f3f;
const int MN = 100005, MS = 1 << 18 | 7;

LL K, W[MN], G[MN], pre[MN], suf[MN];
int N, nxt[MN], Ans;
std::vector<int> T[MN];

#define li (i << 1)
#define ri (li | 1)
#define mid ((l + r) >> 1)
#define ls li, l, mid
#define rs ri, mid + 1, r
LL amn[MS], bmn[MS], ans[MS], tg[MS];
inline void P(int i, LL x) { bmn[i] += x, ans[i] -= x, tg[i] += x; }
inline void Pushdown(int i) { if (tg[i]) P(li, tg[i]), P(ri, tg[i]), tg[i] = 0; }
LL Calc(int i, int l, int r, LL p) {
	if (l == r) return amn[i] - p;
	Pushdown(i);
	if (bmn[li] < p) return std::min(Calc(ls, p), ans[i]);
	else return std::min(amn[li] - p, Calc(rs, p));
}
void Build(int i, int l, int r) {
	if (l == r) { amn[i] = bmn[i] = suf[l]; return ; }
	Build(ls), Build(rs);
	amn[i] = std::min(amn[li], amn[ri]);
	bmn[i] = std::min(bmn[li], bmn[ri]);
	ans[i] = Calc(rs, bmn[li]);
}
void Mdf(int i, int l, int r, int a, int b, LL x) {
	if (r < a || b < l) return ;
	if (a <= l && r <= b) return P(i, x);
	Pushdown(i), Mdf(ls, a, b, x), Mdf(rs, a, b, x);
	bmn[i] = std::min(bmn[li], bmn[ri]);
	ans[i] = Calc(rs, bmn[li]);
}
int Solve2(int i, int l, int r, LL v) {
	if (l == r) return l;
	return amn[ri] <= v ? Solve2(rs, v) : Solve2(ls, v);
}
int Solve(int i, int l, int r, LL p) {
	if (l == r) {
		int ret = amn[i] - p <= K ? l : 0;
		p = std::min(p, bmn[i]);
		return ret;
	}
	Pushdown(i);
	if (bmn[li] < p) {
		if (ans[i] <= K) return Solve(rs, p = bmn[li]);
		else {
			int ret = Solve(ls, p);
			p = std::min(p, bmn[i]);
			return ret;
		}
	} else {
		int ret = amn[li] <= K + p ? Solve2(ls, K + p) : 0;
		return std::max(ret, Solve(rs, p));
	}
}
#undef li
#undef ri
#undef mid
#undef ls
#undef rs

inline void DFS(int u) {
	static int stk[MN], tp;
	stk[++tp] = u;
	if (nxt[u] <= N) Mdf(1, 1, N, nxt[u] - 1, N, pre[u] - pre[nxt[u]]);
	if (u <= N) {
		int lb = 2, rb = tp - 1, mid, ret = 1;
		while (lb <= rb) {
			mid = (lb + rb) >> 1;
			if (pre[stk[mid]] - pre[u] > K) ret = mid, lb = mid + 1;
			else rb = mid - 1;
		}
		int rmax = stk[ret] - 1; LL _ = Infll;
		if (u > 1) Mdf(1, 1, N, 1, u - 1, Infll);
		Mdf(1, 1, N, rmax, N, -Infll);
		int pos = Solve(1, 1, N, _);
		Mdf(1, 1, N, rmax, N, Infll);
		if (u > 1) Mdf(1, 1, N, 1, u - 1, -Infll);
		Ans = std::max(Ans, pos - u + 1);
	}
	for (auto v : T[u]) DFS(v);
	if (nxt[u] <= N) Mdf(1, 1, N, nxt[u] - 1, N, pre[nxt[u]] - pre[u]);
	--tp;
}

inline void Init() {
	static int stk[MN], tp;
	scanf("%d%lld", &N, &K), Ans = 1;
	for (int i = 1; i < N; ++i) scanf("%lld", &W[i]);
	for (int i = 1; i <= N; ++i) scanf("%lld", &G[i]);
	for (int i = 2; i <= N; ++i)
		pre[i] = pre[i - 1] - G[i - 1] + W[i - 1],
		suf[i] = suf[i - 1] - G[i] + W[i - 1];
	pre[N + 1] = Infll, nxt[N + 1] = stk[tp = 1] = N + 1;
	for (int i = N; i >= 1; --i) {
		while (pre[stk[tp]] <= pre[i]) --tp;
		nxt[i] = stk[tp], stk[++tp] = i;
		T[nxt[i]].push_back(i);
	}
}

int main() {
	Init();
	Build(1, 1, N);
	DFS(N + 1);
	printf("%d\n", Ans);
	return 0;
}


T = input()

for _ in xrange(T):
    n, g, b = map(int, raw_input().split())

    if n%2 == 0:
        good = n // 2
        bad = n - good
    else:
        good = n // 2 + 1
        bad = n - good

    if good % g == 0:
        now = (good // g - 1) * (g+b) + g
        rest = (good // g - 1) * b
        if rest < bad:
            now += bad - rest
    else:
        now = (good // g) * (g+b) + (good%g)
        rest = (good // g) * b
        if rest < bad:
            now += bad - rest

    print now


T = input()

for _ in xrange(T):
    n, g, b = map(int, raw_input().split())

    if n%2 == 0:
        reach = n // 2
    else:
        reach = n // 2 + 1

    if reach % g == 0:
        now = (reach // g - 1) * (g+b) + g
    else:
        now = (reach // g) * (g+b) + (reach%g)

    print now


from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout,setrecursionlimit
from itertools import repeat
import math

# sys.stdin = open('input')
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())
def main():
    q = map(int, raw_input().split())[0]
    for _ in range(q):
        n, g, b = map(int, raw_input().split())
        if n%2 == 0:
            need = n/2
        else:
            need = n/2+1
        # print need
        fac, mod = need/g, need%g
        b_need = n-need
        if g>=b:
            print n
        else:
            if mod==0:
                print need + (fac-1)*b
            else:
                print need + (fac-1)*b

main()


from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout,setrecursionlimit
from itertools import repeat
import math

# sys.stdin = open('input')
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())
def main():
    q = map(int, raw_input().split())[0]
    for _ in range(q):
        n, g, b = map(int, raw_input().split())
        if n%2 == 0:
            need = n/2
        else:
            need = n/2+1
        # print need
        fac, mod = need/g, need%g
        b_need = n-need
        if g>=b:
            print n
        else:
            if mod==0:
                print max(need + (fac-1)*b, n, (fac-1)*(g+b)+mod)
            else:
                print max(need + (fac-1)*b, n, (fac)*(g+b)+mod)

main()


from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout,setrecursionlimit
from itertools import repeat
import math

# sys.stdin = open('input')
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())
def main():
    q = map(int, raw_input().split())[0]
    for _ in range(q):
        n, g, b = map(int, raw_input().split())
        if n%2 == 0:
            need = n/2
        else:
            need = n/2+1
        fac, mod = need/g, need%g
        b_need = n-need
        if g>=b:
            print n
        else:
            if mod==0:
                print need + (fac-1)*b
            else:
                print need + fac*b + b_need - fac*g

main()


from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout,setrecursionlimit
from itertools import repeat
import math

# sys.stdin = open('input')
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())
def main():
    q = map(int, raw_input().split())[0]
    for _ in range(q):
        n, g, b = map(int, raw_input().split())
        if n%2 == 0:
            need = n/2
        else:
            need = n/2+1
        # print need
        fac, mod = need/g, need%g
        b_need = n-need
        if g>=b:
            print n
        else:
            if mod==0:
                print max(need + (fac-1)*b, n)
            else:
                print max(need + (fac-1)*b, n)

main()


'''input
3
5 1 1
8 10 10
1000000 1 1000000

'''

RI = lambda : [int(_x) for _x in raw_input().split()]

for _ in range(input()):
	n,g,b=RI()

	ag = n/2 + (n&1)

	no = ag/g + int(ag%g>0)

	tot = (no-1)*(g+b)+ (ag-(no-1)*g)
	ans = max(n,tot)
	print ans


#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def main():
    t = int(input())

    for _ in range(t):
        n, g, b = map(int, input().split())
        h = (n + 1) // 2

        i = (h // g) * (g + b) - (b if h // g else 0) + (h % g)

        print(max(n, i))

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def main():
    t = int(input())

    for _ in range(t):
        n, g, b = map(int, input().split())
        h = (n + 1) // 2

        print(max(n, (h // g) * (g + b) - (b if h // g else 0) + (h % g)))

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def main():
    t = int(input())

    for _ in range(t):
        n, g, b = map(int, input().split())
        #if ((n + 1) // 2) // g == 0:
        #    print(n)
        #else:
        #    print(max(n, (((n + 1) // 2) // g - 1) * (g + b) + min(((n + 1) // 2) % (g + b), g)))
        print(max(n, (((n + 1) // 2) // g - 1) * (g + b) + min(((n + 1) // 2) % (g + b), g)))

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def main():
    t = int(input())

    for _ in range(t):
        n, g, b = map(int, input().split())
        h = (n + 1) // 2

        i = h + (max(0, h // g - 1) * b)

        print(max(n, i))

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def main():
    t = int(input())

    for _ in range(t):
        n, g, b = map(int, input().split())
        h = (n + 1) // 2

        if h // g == 0:
            print(n)
        else:
            print(h + ((h // g) - 1) * b)

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def main():
    t = int(input())

    for _ in range(t):
        n, g, b = map(int, input().split())
        h = n // 2

        i = h + (max(0, h // g - 1) * b)

        print(max(n, i))

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def main():
    t = int(input())

    for _ in range(t):
        n, g, b = map(int, input().split())
        h = (n + 1) // 2
        i = h + (((h + g - 1) // g - 1) * b)
        print(max(n, i))

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def main():
    t = int(input())

    for _ in range(t):
        n, g, b = map(int, input().split())
        if ((n + 1) // 2) // g == 0:
            print(n)
        else:
            print(max(n, (((n + 1) // 2) // g - 1) * (g + b) + min(((n + 1) // 2) % (g + b), g)))

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


from __future__ import division,print_function
#from sortedcontainers import SortedList
import sys
#sys.__stdout__.flush()
le=sys.__stdin__.read().split("\n")
le.pop()
le=le[::-1]
for k in range(int(le.pop())):
    n,b,g=list(map(int,le.pop().split()))
    h=(n+1)//2
    q=(h-1)//b
    r=(h-1)%b+1
    #print(r,q)
    print(max(r+q*(b+g),n))


for _ in range(input()):
    N,G,B = map(int,raw_input().split())
    target = (N+1)/2
    k = (target-1) / G
    rest = target - k * G
    ans = k * (G + B) + rest
    if ans < N: ans = N
    print ans


import sys
range = xrange
input = raw_input

inp = [int(x) for x in sys.stdin.read().split()]; ii = 0

t = inp[ii]; ii += 1
out = []
for _ in range(t):
    n = m = inp[ii]; ii += 1
    g = inp[ii]; ii += 1
    b = inp[ii]; ii += 1

    good = n + 1 >> 1

    cycles, good = divmod(good - 1, g)
    good += 1

    n -= cycles * (g + b)
    n -= good
    if n <= 0:
        print cycles * (g + b) + good
        continue
    print m


rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

def solve(N, G, B):
    target = (N + 1) // 2
    def possible(D):
        # can we do it in D days
        Q, R = divmod(D, G+B)
        good = Q * G + min(R, G)
        #bad = Q * B + max(R-G, 0)
        return good >= target

    lo, hi = N, 10 ** 20
    while lo < hi:
        mi = lo + hi >> 1
        if possible(mi):
            hi = mi
        else:
            lo = mi + 1
    return lo

for _ in range(rri()):
    print solve(*rrm())


for _ in range(input()):
    n,g,b=map(int,raw_input().split())
    if(g>=b):
        print n
    else:
        f=(n+1)/2

        print(f+(((f+g-1)/g)-1)*b)


for _ in range(input()):
    n,g,b=map(int,raw_input().split())
    if(g>=b):
        print n
    else:
        f=(n+1)/2
        if(f%g==0):
            t=(f/g-1)*b
            k=(n-f-t)
            if k<0:
                k=0
            print(f+(f/g-1)*b+k)
        else:
            print(f+(f/g)*b)


for _ in range(input()):
    n,g,b=map(int,raw_input().split())
    if(g>=b):
        print n
    else:
        f=(n+1)/2
        tc=f+(max((f+g-1)/g-1,0))*b
        ts=f+max((((f+g-1)/g-1)*b),0)

        if ts>=n:
            print tc
        else:
            print tc+n-ts


for _ in range(input()):
    n,g,b=map(int,raw_input().split())
    if(g>=b):
        print n
    else:
        f=(g+1)/2
        print(f+(f/g)*b)


'''input
3
3 1 2
8 10 10
1000000 1 1000000
'''

import sys
debug = 1
readln = sys.stdin.readline
#sys.setrecursionlimit(1000000)

def write(s):
    sys.stdout.write(str(s))

def writeln(s):
    sys.stdout.write(str(s))
    sys.stdout.write('\n')

def readint():
    return int(readln().strip())

def readints():
    return map(int, readln().split())

def readstr():
    return readln().strip()

def readstrs():
    return readln().split()

def dprint(*args):
    if debug: print(' '.join(map(str, args)))

def solve(n,g,b):
    ans = 0
    left = n
    maxBad = n / 2
    maxBadRound = maxBad / b
    if maxBadRound * (g+b) >= n:
        return n
    ans += maxBadRound * (g+b)
    left -= maxBadRound * (g+b)
    maxBad -= maxBadRound * b

    if maxBad > 0:
        if g + maxBad >= left:
            return n
        ans += (g+b)
        left -= g + maxBad

    maxFullRound = (left-1) / g
    ans += maxFullRound * (g+b)
    left -= maxFullRound * g

    return ans + left

t = readint()
for _ in xrange(t):
    n,g,b = readints()
    writeln(solve(n,g,b))


'''input
3
5 1 1
8 10 10
1000000 1 1000000
'''

import sys
debug = 1
readln = sys.stdin.readline
#sys.setrecursionlimit(1000000)

def write(s):
    sys.stdout.write(str(s))

def writeln(s):
    sys.stdout.write(str(s))
    sys.stdout.write('\n')

def readint():
    return int(readln().strip())

def readints():
    return map(int, readln().split())

def readstr():
    return readln().strip()

def readstrs():
    return readln().split()

def dprint(*args):
    if debug: print(' '.join(map(str, args)))

def solve(n,g,b):
    ans = 0
    left = n
    maxBad = n - n / 2
    maxBadRound = maxBad / b
    if maxBadRound * (g+b) >= n:
        return n
    ans += maxBadRound * (g+b)
    left -= maxBadRound * (g+b)
    maxBad -= maxBadRound * b

    if maxBad > 0:
        if g + maxBad >= left:
            return n
        ans += (g+b)
        left -= g + maxBad

    maxFullRound = (left-1) / g
    ans += maxFullRound * (g+b)
    left -= maxFullRound * g

    return ans + left

t = readint()
for _ in xrange(t):
    n,g,b = readints()
    writeln(solve(n,g,b))


t=int(input())
for i in range(t):
    n,g,b=list(map(int,input().split()));
    l=0;r=1e30;
    # print("GOOD")
    while(l+1<r):
        m=int((r+l)/2);
        k=m//(g+b);
        r2=m%(g+b);
        res=k*g+(min(r2,g));
        # print("CHECK ",l,r,m)
        if(res>=((n+1)//2)):
            r=m;
        else:
            l=m;
    print(max(r,n))


t=int(input())
for i in range(t):
    n,g,b=list(map(int,input().split()));
    k=((((n+1)//2)-1)//g)+1
    r=(k-1)*(g+b)+g
    print(max(r,n))


t=int(input())
for i in range(t):
    n,g,b=list(map(int,input().split()));
    l=0;r=1e24;
    # print("GOOD")
    while(l+1<r):
        m=(r+l)//2;
        k=m//(g+b);
        r2=m%(g+b);
        res=k*g+(min(r2,g));
        # print("CHECK ",l,r,m)
        if(res>=((n+1)//2)):
            r=m;
        else:
            l=m;
    print(int(max(r,n)))


#include<bits/stdc++.h>
using namespace std;
#define int long long
string f(int a){
    if(a==0){
        return "";
    }
    if(a%2==1){
        return f(a/2)+"1";
    }else{
        return f(a/2)+"0";
    }
}
signed main(){
    ios::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        int n,g,b;
        cin>>n>>g>>b;
        int l=0,r=1e18;
        while(l+1!=r){
            int m=(r+l)/2;
            int k=m/(g+b);
            int r2=m%(g+b);
            int res=k*g+(min(r2,g));
//            cout<<"CHECK "<<l<<" "<<m<<" "<<r<<" "<<res<<endl;
            if(res>=((n+1)/2)){
                r=m;
            }else{
                l=m;
            }
        }
        cout<<max(r,n)<<endl;
    }
}


t=int(input())
for i in range(t):
    n,g,b=list(map(int,input().split()));
    l=0;r=1e24;
    # print("GOOD")
    while(l+1<r):
        m=(r+l)//2;
        k=m//(g+b);
        r2=m%(g+b);
        res=k*g+(min(r2,g));
        # print("CHECK ",l,r,m)
        if(res>=((n+1)//2)):
            r=m;
        else:
            l=m;
    print(max(r,n))


from math import ceil
for _ in range(int(input())):
    n,g,b=map(int,input().split())
    if g>=b:
        print(n)
    else:
        n1=ceil(n/2)
        ans=(g+b)*ceil(n1/g)-b
        ans-=(n1)%g
        if n>ans:
            ans=n
        print(ans)


from math import ceil
for _ in range(int(input())):
    n,g,b=map(int,input().split())
    if g>=b:
        print(n)
    else:
        n1=(n-1)//2+1
        ans=(g+b)*ceil(n1/g)-b
        print(ans)


for _ in range(int(input())):
    n,g,b=map(int,input().split())
    if g>=b:
        print(n)
    else:
        n1=(n-1)//2+1
        ans=n1+b*((n1-1)//g)
        print(max(ans,n))


from math import ceil
for _ in range(int(input())):
    n,g,b=map(int,input().split())
    if g>=b:
        print(n)
    else:
        n1=ceil(n/2)
        ans=(g+b)*ceil(n1/g)-b
        if n>ans:
            print(n)
            continue
        ans-=(n1)%g
        print(ans)


from math import ceil
for _ in range(int(input())):
    n,g,b=map(int,input().split())
    if g>=b:
        print(n)
    else:
        n1=ceil(n/2)
        ans=(g+b)*ceil(n1/g)-b
        if n>ans:
            ans=n
        print(ans)


from math import ceil
for _ in range(int(input())):
    n,g,b=map(int,input().split())
    n1=ceil(n/2)
    ans=(g+b)*ceil(n1/g)-b
    if n>ans:
        print(n)
        continue
    ans-=(n1)%g
    print(ans)


import math
for _ in range(int(input())):
    n,g,b=map(int,input().split())
    target=math.ceil(n/2)
    gp=0
    bp=0
    isg=True
    ans=0
    # while n>0:
    #     if isg:
    #         gp+=min(n,g)

    #         ans+=min(n,g)
    #         n-=min(n,g)
    #     else:
    #         if gp>=target:
    #             bp+=min(n,b)
    #             ans+=min(n,b)
    #             n-=min(n,b)
    #         else:
    #             rem=n-(min(n,b))
    #             if rem+gp>=target:

    #                 bp+=min(n,b)
    #                 ans+=min(n,b)
    #                 n-=min(n,b)
    #             else:
    #                 req=target-gp
    #                 b_can_take=max(n-req,0)
    #                 ans+=b
    #                 bp+=b_can_take
    #                 n=n-b_can_take
    #     isg=not isg
    l=0
    r=1e10
    x=0
    while l<=r:
        mid=(l+r)//2
        rem=n-mid*(g+b)
        gp=mid*g
        if gp+rem>=target and n-mid*(g+b)>=0:
            x=int(mid)
            l=mid+1
        else:
            r=mid-1
    rem=n-x*(g+b)
    ans+=x*(g+b)
    gp=x*g
    req=target-gp
    if req<=g:
        print(ans+rem)
    else:
        ans+=g
        req-=g
        rem-=g
        #using last bp
        rem1=max(rem-req,0)
        ans+=b
        rem-=rem1
        y=rem//(g)
        ans+=max(y*(g+b)-b,0)
        rem-=y*g
        if rem>0:
            ans+=b
        ans+=rem
        print(ans)


import math
for _ in range(int(input())):
    n,g,b=map(int,input().split())
    target=math.ceil(n/2)
    gp=0
    bp=0
    isg=True
    ans=0
    # while n>0:
    #     if isg:
    #         gp+=min(n,g)

    #         ans+=min(n,g)
    #         n-=min(n,g)
    #     else:
    #         if gp>=target:
    #             bp+=min(n,b)
    #             ans+=min(n,b)
    #             n-=min(n,b)
    #         else:
    #             rem=n-(min(n,b))
    #             if rem+gp>=target:

    #                 bp+=min(n,b)
    #                 ans+=min(n,b)
    #                 n-=min(n,b)
    #             else:
    #                 req=target-gp
    #                 b_can_take=max(n-req,0)
    #                 ans+=b
    #                 bp+=b_can_take
    #                 n=n-b_can_take
    #     isg=not isg
    l=0
    r=1e9
    x=0
    while l<=r:
        mid=(l+r)//2
        rem=n-mid*(g+b)
        gp=mid*g
        if gp+rem>=target and n-mid*(g+b)>=0:
            x=int(mid)
            l=mid+1
        else:
            r=mid-1
    rem=n-x*(g+b)
    ans+=x*(g+b)
    gp=x*g
    req=target-gp
    if req<=g:
        print(ans+rem)
    else:
        ans+=g
        req-=g
        rem-=g
        #using last bp
        rem1=max(rem-req,0)
        ans+=b
        rem-=rem1
        y=rem//(g)
        #print(rem1,rem,req,y,ans)
        ans+=max(y*(g+b)-b,0)
        rem-=y*g
        ans+=rem
        print(ans)


import math
for _ in range(int(input())):
    n,g,b=map(int,input().split())
    target=math.ceil(n/2)
    gp=0
    bp=0
    isg=True
    ans=0
    # while n>0:
    #     if isg:
    #         gp+=min(n,g)

    #         ans+=min(n,g)
    #         n-=min(n,g)
    #     else:
    #         if gp>=target:
    #             bp+=min(n,b)
    #             ans+=min(n,b)
    #             n-=min(n,b)
    #         else:
    #             rem=n-(min(n,b))
    #             if rem+gp>=target:

    #                 bp+=min(n,b)
    #                 ans+=min(n,b)
    #                 n-=min(n,b)
    #             else:
    #                 req=target-gp
    #                 b_can_take=max(n-req,0)
    #                 ans+=b
    #                 bp+=b_can_take
    #                 n=n-b_can_take
    #     isg=not isg
    l=0
    r=1e10
    x=0
    while l<=r:
        mid=(l+r)//2
        rem=n-mid*(g+b)
        gp=mid*g
        if gp+rem>=target and n-mid*(g+b)>=0:
            x=int(mid)
            l=mid+1
        else:
            r=mid-1
    rem=n-x*(g+b)
    ans+=x*(g+b)
    gp=x*g
    req=target-gp
    if req<=g:
        print(ans+rem)
    else:
        ans+=g
        req-=g
        rem-=g
        #using last bp
        rem1=max(rem-req,0)
        ans+=b
        rem-=rem1
        y=rem//(g)
        #print(rem1,rem,req,y,ans)
        ans+=max(y*(g+b)-b,0)
        rem-=y*g
        ans+=rem
        print(ans)


import math
for _ in range(int(input())):
    n,g,b=map(int,input().split())
    target=math.ceil(n/2)
    gp=0
    bp=0
    isg=True
    ans=0
    # while n>0:
    #     if isg:
    #         gp+=min(n,g)

    #         ans+=min(n,g)
    #         n-=min(n,g)
    #     else:
    #         if gp>=target:
    #             bp+=min(n,b)
    #             ans+=min(n,b)
    #             n-=min(n,b)
    #         else:
    #             rem=n-(min(n,b))
    #             if rem+gp>=target:

    #                 bp+=min(n,b)
    #                 ans+=min(n,b)
    #                 n-=min(n,b)
    #             else:
    #                 req=target-gp
    #                 b_can_take=max(n-req,0)
    #                 ans+=b
    #                 bp+=b_can_take
    #                 n=n-b_can_take
    #     isg=not isg
    l=0
    r=1e10
    x=0
    while l<=r:
        mid=(l+r)//2
        rem=n-mid*(g+b)
        gp=mid*g
        if gp+rem>=target and n-mid*(g+b)>=0:
            x=int(mid)
            l=mid+1
        else:
            r=mid-1
    rem=n-x*(g+b)
    ans+=x*(g+b)
    gp=x*g
    req=target-gp
    if req<=g:
        print(ans+rem)
    else:
        ans+=g
        req-=g
        rem-=g
        #using last bp
        rem1=max(rem-req,0)
        ans+=b
        rem-=rem1
        y=rem//(g)
        ans+=max(y*(g+b)-b,0)
        rem-=y*g
        if rem>0 and y>0:
            ans+=b
        ans+=rem
        print(ans)


import math
for _ in range(int(input())):
    n,g,b=map(int,input().split())
    target=math.ceil(n/2)
    gp=0
    bp=0
    isg=True
    ans=0
    while n>0:
        if isg:
            gp+=min(n,g)

            ans+=min(n,g)
            n-=min(n,g)
        else:
            if gp>=target:
                bp+=min(n,b)
                ans+=min(n,b)
                n-=min(n,b)
            else:
                rem=n-(min(n,b))
                if rem+gp>=target:

                    bp+=min(n,b)
                    ans+=min(n,b)
                    n-=min(n,b)
                else:
                    req=target-gp
                    b_can_take=max(n-req,0)
                    ans+=b
                    bp+=b_can_take
                    n=n-b_can_take
        isg=not isg
    print(ans)


import math
for _ in range(int(input())):
    n,g,b=map(int,input().split())
    target=math.ceil(n/2)
    gp=0
    bp=0
    isg=True
    ans=0
    # while n>0:
    #     if isg:
    #         gp+=min(n,g)

    #         ans+=min(n,g)
    #         n-=min(n,g)
    #     else:
    #         if gp>=target:
    #             bp+=min(n,b)
    #             ans+=min(n,b)
    #             n-=min(n,b)
    #         else:
    #             rem=n-(min(n,b))
    #             if rem+gp>=target:

    #                 bp+=min(n,b)
    #                 ans+=min(n,b)
    #                 n-=min(n,b)
    #             else:
    #                 req=target-gp
    #                 b_can_take=max(n-req,0)
    #                 ans+=b
    #                 bp+=b_can_take
    #                 n=n-b_can_take
    #     isg=not isg
    l=0
    r=1e9
    x=0
    while l<=r:
        mid=(l+r)//2
        rem=n-mid*(g+b)
        gp=mid*g
        if gp+rem>=target and n-mid*(g+b)>=0:
            x=int(mid)
            l=mid+1
        else:
            r=mid-1
    rem=n-x*(g+b)
    ans+=x*(g+b)
    gp=x*g
    req=target-gp
    if req<=g:
        print(ans+rem)
    else:
        ans+=g
        req-=g
        rem-=g
        #using last bp
        rem1=max(rem-req,0)
        ans+=b
        rem-=rem1
        y=rem//(g)
        #print(rem1,rem,req,y,ans)
        ans+=y*(g+b)-b
        rem-=y*g
        ans+=rem
        print(ans)


T = int(input())
for _ in range(T):
    n, g, b = map(int, input().split())
    if g >= b:
        print(n)
    else:
        n = n - n//2
        q = n // g
        r = n % g
        ans = q*(g+b) + r
        if r == 0:
            ans -= b
        print(ans)


T = int(input())
for _ in range(T):
    n, g, b = map(int, input().split())
    if g >= b:
        print(n)
    else:
        good = n - n//2
        bad = n//2
        x = good // g
        r = good % g
        y = bad // b
        s = bad % b
        if x == y:
            if s == 0:
                print(x*(g+b)+r)
            else:
                print(x*(g+b)+g+s)
        elif x < y:
            if s == 0:
                print(y*(g+b))
            else:
                print(y*(g+b)+g+s)
        elif x == y + 1:
            if r == 0:
                print((x-1)*(g+b)+g+s)
            else:
                print(x*(g+b)+r)
        else:
            if r == 0:
                print((x-1)*(g+b)+g)
            else:
                print(x*(g+b)+r)


T = int(input())
for _ in range(T):
    n, g, b = map(int, input().split())
    if g >= b:
        print(n)
    else:
        x = n // (2*g)
        r = n % (2*g)
        if r == 0:
            if (x-1) * (b-g) >= g:
                print((x-1) * (g+b) + g)
            else:
                print((x-1) * (g+b) + 2*g - (x-1) * (b-g))
        elif r <= g:
            print(x*(g+b)+r)
        else:
            if x == 0:
                print(r)
            else:
                s = r - g
                if x * (b-g) >= s:
                    print(x * (g+b) + g)
                else:
                    print(x * (g+b) + g + s - x * (b-g))


T = int(input())
for _ in range(T):
    n, g, b = map(int, input().split())
    if g >= b:
        print(n)
    else:
        good = n - n//2
        bad = n//2
        x = good // g
        r = good % g
        y = bad // b
        s = bad % b
        print(x, r, y, s)
        if x == y:
            if s == 0:
                print(x*(g+b)+r)
            else:
                print(x*(g+b)+g+s)
        elif x < y:
            if s == 0:
                print(y*(g+b))
            else:
                print(y*(g+b)+g+s)
        elif x == y + 1:
            if r == 0:
                print((x-1)*(g+b)+g+s)
            else:
                print(x*(g+b)+r)
        else:
            if r == 0:
                print((x-1)*(g+b)+g)
            else:
                print(x*(g+b)+r)


T = int(input())
for _ in range(T):
    n, g, b = map(int, input().split())
    if g >= b:
        print(n)
    else:
        good = n - n//2
        bad = n//2
        x = good // g
        r = good % g
        y = bad // b
        s = bad % b
        if r == 0:
            x -= 1
            r = g
        if s == 0:
            y -= 1
            s = b
        if x == y:
            print(x*(g+b)+r+s)
        else:
            print(x*(g+b)+r)


def round(x):
    if not x % 2:
        return x // 2
    return x // 2 + 1

T = int(input())
for i in range(T):
    n, g, b = [int(j) for j in input().split()]
    if n <= g:
        print(n)
        continue
    n = round(n)
    good = n // g
    if not n % g:
        good -= 1
    n -= good * g
    print(max((b + g) * good + n, n))


def round(x):
    if x % 2 == 0:
        return x // 2
    return x // 2 + 1

T = int(input())
for i in range(T):
    n, g, b = [int(j) for j in input().split()]
    if n <= g:
        print(n)
        continue
    n = round(n)
    good = n // g
    if not n % g:
        good -= 1
    n -= good * g
    print((b + g) * good + n)


def round(x):
    if not x % 2:
        return x // 2
    return x // 2 + 1

T = int(input())
for i in range(T):
    n, g, b = [int(j) for j in input().split()]
    n0 = n
    if n <= g:
        print(n)
        continue
    n = (n + 1) // 2
    good = (n - 1) // g
    print(good * b + n)


def round(x):
    if not x % 2:
        return x // 2
    return x // 2 + 1

T = int(input())
for i in range(T):
    n, g, b = [int(j) for j in input().split()]
    n0 = n
    n = (n + 1) // 2
    good = (n - 1) // g
    print(max(good * b + n, n0))


def round(x):
    if not x % 2:
        return x // 2
    return x // 2 + 1

T = int(input())
for i in range(T):
    n, g, b = [int(j) for j in input().split()]
    n0 = n
    if n <= g:
        print(n)
        continue
    n = round(n)
    good = (n - 1) // g
    print(good * b + n)


def ceil(d):
    if d == int(d):
        return d
    else:
        return int(d)+1
for _ in range(int(input())):
    n,g,b = list(map(int, input().split()))
    k = ceil(n/2)
    if g >= b or k <= g:
        print(n)
        continue
    else:
        x = int((k-g)/g)
        t = ceil((k-g)/g - x)
        ans = g + x*(b+g) + t*g
        print(max(n, int(ans)))


## necessary imports
import sys
input = sys.stdin.readline
from math import log2, log, ceil

# swap_array function
def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp

## gcd function
def gcd(a,b):
    if a == 0:
        return b
    return gcd(b%a, a)

## nCr function efficient using Binomial Cofficient
def nCr(n, k):
    if(k > n - k):
        k = n - k
    res = 1
    for i in range(k):
        res = res * (n - i)
        res = res / (i + 1)
    return res

## upper bound function code -- such that e in a[:i] e < x;
def upper_bound(a, x, lo=0):
    hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x:
            lo = mid+1
        else:
            hi = mid
    return lo

## prime factorization
def primefs(n):
    ## if n == 1    ## calculating primes
    primes = {}
    while(n%2 == 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    ## prime factoriazation of n is stored in dictionary
    ## primes and can be accesed. O(sqrt n)
    return primes

## MODULAR EXPONENTIATION FUNCTION
def power(x, y, p):
    res = 1
    x = x % p
    if (x == 0) :
        return 0
    while (y > 0) :
        if ((y & 1) == 1) :
            res = (res * x) % p
        y = y >> 1
        x = (x * x) % p
    return res

## DISJOINT SET UNINON FUNCTIONS
def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b

# find function
def find(x, link):
    while(x != link[x]):
        x = link[x]
    return x

# the union function which makes union(x,y)
# of two nodes x and y
def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x

## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES
def sieve(n):
    prime = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime

#### PRIME FACTORIZATION IN O(log n) using Sieve ####
MAXN = int(1e6 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    ## function for storing smallest prime factors (spf) in the array

################## un-comment below 2 lines when using factorization #################
# spf = [0 for i in range(MAXN)]
# spf_sieve()
def factoriazation(x):
    ret = {};
    while x != 1:
        ret[spf[x]] = ret.get(spf[x], 0) + 1;
        x = x//spf[x]
    return ret
    ## this function is useful for multiple queries only, o/w use
    ## primefs function above. complexity O(log n)

## taking integer array input
def int_array():
    return list(map(int, input().strip().split()))
## taking string array input
def str_array():
    return input().strip().split();

#defining a couple constants
MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');

################### ---------------- TEMPLATE ENDS HERE ---------------- ###################

for _ in range(int(input())):
    n, g, b = int_array();
    x = ceil(n/2); pairs = ceil(x/g)-1;
    ans = pairs*(g+b); rem = x - pairs*g;
    ans += rem; print(max(ans, n));


import math
for _ in range(int(input())):
    n,g,b = list(map(int, input().split()))
    k = math.ceil(n/2)
    if g >= b or k <= g:
        print(n)
        continue
    else:
        x = math.ceil((k-g)/g)
        t= math.floor((k-g)/g)
        ans = g + x*b + t*g + (k-g)%g
        print(ans)


def ceil(d):
    if d == int(d):
        return d
    else:
        return int(d)+1
for _ in range(int(input())):
    n,g,b = list(map(int, input().split()))
    k = ceil(n/2)
    if g >= b or k <= g:
        print(n)
        continue
    else:
        x = int((k-g)/g)
        t = ceil((k-g)/g - x)
        ans = g + x*(b+g) + t*g
        print(int(ans))


for _ in range(int(input())):
    n,g,b = list(map(int, input().split()))
    k = (n+1)//2
    ans = (g+b)*(k//g)
    if k % g == 0:
        ans -= b
    else:
        ans += k%g
    print(max(n, ans))


import math
for _ in range(int(input())):
    n,g,b = list(map(int, input().split()))
    k = math.ceil(n/2)
    if g >= b or k <= g:
        print(n)
        continue
    else:
        x = math.floor((k-g)/g)
        t = math.ceil((k-g)/g - x)
        ans = g + x*(b+g) + t*g
        print(ans)


a=int(input())
for i in range(a):
    n,g,b=map(int,input().split())
    if(n%2==1):
        n=(n//2)+1
    else:
        n=n//2
    if(g>=n):
        print(n)
        continue;
    else:
        t=n//g
        k=n%g
        if(k==0):
            print((g+b)*t-b)
        else:
            print((g+b)*t+k)


a=int(input())
for i in range(a):
    n,g,b=map(int,input().split())
    if(g>=n):
        print(n)
        continue;
    if(n%2==1):
        pak=n//2+1
    else:
        pak=n//2
    l=pak//g
    r=pak%g
    if(b>=g):
        if(l==0):
            print(l*(g+b))
        else:
            print(l*(g+b)+r)
    else:
        print(n)


a=int(input())
for i in range(a):
    n,g,b=map(int,input().split())
    if(n<=g):
        print(n)
        continue;
    if(n%2==1):
        pak=n//2+1
    else:
        pak=n//2
    l=pak//g
    r=pak%g
    days=(g+b)*l-b
    if(n<=days):
        print(days)
    else:
        print(n)


a=int(input())
for i in range(a):
    n,g,b=map(int,input().split())
    if(g>=n):
        print(n)
        continue;
    if(n%2==1):
        n=(n//2)+1
    else:
        n=n//2

    t=n//g
    k=n%g
    if(k==0):
        print((g+b)*t-b)
    else:
        print((g+b)*t+k)


a=int(input())
for i in range(a):
    n,g,b=map(int,input().split())
    if(n%2==1):
        n=(n//2)+1
    else:
        n=n//2
    if(g>=n):
        print(g)
        continue;
    else:
        t=n//g
        k=n%g
        if(k==0):
            print((g+b)*t-b)
        else:
            print((g+b)*t+k)


a=int(input())
for i in range(a):
    n,g,b=map(int,input().split())

    if(g>=n):
        print(n)
        continue;
    else:
        t=n//g
        k=n%g
        if(k==0):
            print((g+b)*t-b)
        else:
            print((g+b)*t+k)


a=int(input())
for i in range(a):
    n,g,b=map(int,input().split())
    if(g>=n):
        print(n)
        continue;
    if(n%2==1):
        n=(n//2)+1
    else:
        n=n//2

    else:
        t=n//g
        k=n%g
        if(k==0):
            print((g+b)*t-b)
        else:
            print((g+b)*t+k)


a=int(input())
for i in range(a):
    n,g,b=map(int,input().split())
    if(n<=g):
        print(n)
        continue;
    if(n%2==1):
        pak=(n//2)+1
    else:
        pak=n//2
    l=pak//g
    r=pak%g
    if(r==0):
        days=(g+b)*l-b
    else:
        days=(g+b)*l+r

    if(n<=days):
        print(days)
    else:
        print(n)


for _ in range(int(input())):
	n,g,b=map(int,input().split())
	need=(n+1)//2
	cyc=(need+g-1)//g
	ans=(g+b)*cyc-b
	ans-=(g-need%g)%g
	print(max(ans,n))


for _ in range(int(input())):
	n,g,b=map(int,input().split())
	need=(n+1)//2
	cyc=(need+g-1)//g
	ans=(g+b)*cyc-b
	ans-=need%g
	print(max(ans,n))


for _ in range(int(input())):
    n,g,b=map(int,input().split())
    pol=(n+1)//2
    psme=(pol+g-1)//g
    ans=psme*(g+b)-b-(psme*g-pol)
    print(max(ans,n))


import math
for t in range(int(input())):
    length,good,bad=map(int,input().split())
    good_len=math.ceil(length/2)
    complete_cycle_days=math.floor(good_len/good)*(good+bad)
    no_of_good_more=good_len-(math.floor(good_len/good)*good)
    if no_of_good_more==0:
        complete_cycle_days-=bad
    complete_cycle_days+=no_of_good_more
    print(max(length,complete_cycle_days))


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush,heappop,heapify
from itertools import permutations,combinations
mod = int(1e9)+7

ip = lambda : int(stdin.readline())
inp = lambda: map(int,stdin.readline().split())
ips = lambda: stdin.readline().rstrip()
out = lambda x : stdout.write(str(x)+"\n")

t = ip()
for _ in range(t):
    n,g,b = inp()
    if n//2 <= g:
        ans = n
    else:
        half = n//2
        g_times = half//g
        ans = g_times*g
        g_rem = half%g
        if g_rem == 0:
            ans += (g_times-1)*b
        else:
            ans += (g_times*b)
        ans = max(ans,n)
        ans += g_rem
    out(ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush,heappop,heapify
from itertools import permutations,combinations
mod = int(1e9)+7

ip = lambda : int(stdin.readline())
inp = lambda: map(int,stdin.readline().split())
ips = lambda: stdin.readline().rstrip()
out = lambda x : stdout.write(str(x)+"\n")

t = ip()
for _ in range(t):
    n,g,b = inp()
    if n//2 <= g:
        ans = n
    else:
        half = n//2
        g_times = half//g
        ans = g_times*g
        g_rem = half%g
        if g_rem == 0:
            ans += (g_times-1)*b
        else:
            ans += (g_times-1)*b
        ans += g_rem
        left = (g_times-1)*b
        if n-n//2<=left:
            pass
        else:
            ans += (n-n//2-left)
    out(ans)


import math

T = int(input())
for _ in range(T):
	n, g, b = map(int, input().split(' '))
	goodtiles = math.ceil(n / 2)

	daysneeded = (g + b) * (goodtiles // g)
	print('daysneed',daysneeded)

	if goodtiles % g != 0:
		print(max(n, daysneeded + goodtiles % g))

	elif goodtiles % g == 0:
		print(max(n, daysneeded - b))


import math

T = int(input())
for _ in range(T):
	n, g, b = map(int, input().split(' '))
	goodtiles = math.ceil(n / 2)

	daysneeded = (g + b) * (goodtiles // g)
	#print('daysneed',daysneeded)

	if goodtiles % g != 0:
		print(max(n, daysneeded + goodtiles % g))

	elif goodtiles % g == 0:
		print(max(n, daysneeded - b))


import math

T = int(input())
for _ in range(T):
	n, g, b = map(int, input().split(' '))
	original = n
	n = math.ceil(n / 2)

	if g >= n:
		print(original)
		continue

	pair = g + b

	number_of_pairs = math.ceil(n / g)
	#print('numberofpairs: ', number_of_pairs)
	print(number_of_pairs*g + (number_of_pairs-1)*b)


import math

T = int(input())
for _ in range(T):
	n, g, b = map(int, input().split(' '))
	original = n
	n = math.ceil(n / 2)

	if g >= n:
		print(g)
		continue

	pair = g + b

	number_of_pairs = math.ceil(n / g)
	#print('numberofpairs: ', number_of_pairs)
	print(number_of_pairs*g + (number_of_pairs-1)*b)


import math

T = int(input())
for _ in range(T):
	n, g, b = map(int, input().split(' '))
	goodtiles = math.ceil(n / 2)

	daysneeded = (g + b) * (goodtiles // g)
	gs = g * (goodtiles // g)

	if gs == g:
		print(max(n, daysneeded - b))

	else:
		print(max(n, daysneeded + goodtiles - g))


import math

T = int(input())
for _ in range(T):
	n, g, b = map(int, input().split(' '))
	goodtiles = math.ceil(n / 2)

	daysneeded = (g + b) * (goodtiles // g)
	if daysneeded % g == 0:
		print(max(n, daysneeded - b))

	else:
		print(max(n, daysneeded + daysneeded % g))


t = int(input())

def f(n,g,b):
    ideal = (n+1)//2
    ost = n - ideal
    #print(ost)
    ans = 0
    pb = 0
    if n == 1:
        return 1
    while ideal > 0:
        if ideal <= g:
            ans += ideal
            if pb >= ost:
                return ans + pb
            else:
                return ans + ost
        else:
            ideal -= g
            ans += g
            pb += b

for i in range(t):
    l = input()
    n = int(l.split()[0])
    g = int(l.split()[1])
    b = int(l.split()[2])
    print(f(n,g,b))


t = int(input())

def f(n,g,b):
    ideal = (n+1)//2
    ost = n - ideal
    #print(ost)
    ans = 0
    pb = 0
    while ideal > 0:
        if ideal <= g:
            ans += ideal
            if pb >= ost:
                return ans + pb
            else:
                return ans + ost
        else:
            ideal -= g
            ans += g
            pb += b

for i in range(t):
    l = input()
    n = int(l.split()[0])
    g = int(l.split()[1])
    b = int(l.split()[2])
    print(f(n,g,b))


t = int(input())

def f(n,g,b):
    ideal = (n+1)//2
    ost = n - ideal
    #print(ost)
    ans = 0
    pb = 0
    if n == 1:
        return 1
    if ideal % g == 0:
        pb = ideal // g - 1
    else: pb = ideal // g
    if ideal + pb * b >= n:
        return ideal + pb * b
    else:
        return n

for i in range(t):
    l = input()
    n = int(l.split()[0])
    g = int(l.split()[1])
    b = int(l.split()[2])
    print(f(n,g,b))


#include<algorithm>
#include<stdio.h>
#define ll long long
using namespace std;
ll n,k,maxx;
bool check(ll now){return k*(k+1)/2<=(n/now);}
int main()
{
	scanf("%lld %lld",&n,&k);
	ll k2=(k-1)*k/2;
	for(ll u=1;u*u<=n;u+=1)
	{
		if(n%u!=0)continue;
		if(check(u))maxx=max(maxx,u);
		if(check(n/u))maxx=max(maxx,n/u);
	}
	if(!maxx)puts("-1");
	else
	{
		for(register ll u=1;u<k;u+=1)printf("%lld ",u*maxx);
		printf("%lld",maxx*(n/maxx-k2));
	}
	return 0;
}


// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
long long n,k,gcd;
int main()
{
	long long i,j;
	scanf("%lld %lld",&n,&k);
	if(((1+k)*k/2)>n||k>100000)
	{
		printf("-1");
		return 0;
	}
	gcd=((1+k)*k/2)-1;
	while(1)
	{
//		printf("%lld\n",gcd);
		gcd++;
		if(n%gcd==0)break;
	}
	gcd=n/gcd;
	n/=gcd;
	for(i=1;i<k;i++)
	{
		cout<<i*gcd<<" ";
		n-=i;
	}
	cout<<n*gcd;
	return 0;
}


// luogu-judger-enable-o2
#include<iostream>
#include<cmath>
#include<cstdio>
#pragma GCC optimize(2)
using namespace std;
long long n,k,cnt,ans,flag,yinshu[500010];
int main()
{
//	freopen("未命名1.out","w",stdout);
	scanf("%lld%lld",&n,&k);
	if(k==1)
	{
		cout<<n;
		return 0;
	}
	if(n<k*(k+1)/2)
	{
		cout<<-1;
		return 0;
	}
	long long pingfanggen=sqrt(n);
	for(int i=1;i<=pingfanggen;i++)
		if(n%i==0)
			yinshu[++cnt]=i;
	long long fuben=cnt;
	for(int i=fuben;i>=1;i--)
		yinshu[++cnt]=n/yinshu[i];
//	for(int i=1;i<=cnt;i++)
//		cout<<yinshu[i]<<endl;
	long long mmm=k*(1+k)/2;
	for(int i=cnt;i>=1;i--)
		if(n/yinshu[i]>=mmm)
		{
			flag=1;
			ans=i;
			break;
		}
	if(flag==0)
	{
		cout<<-1;
		return 0;
	}
	for(int i=1;i<k;i++)
		printf("%lld ",i*yinshu[ans]);
	printf("%lld",n-yinshu[ans]*k*(k-1)/2);
	return 0;
}


// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,k,tmp,tp,sum,fac[5005];
int faccnt;
inline void factor(ll x)
{
	for(register ll i=sqrt(x);i;--i)
	{
		if(x%i) continue;
		fac[++faccnt]=i;
		fac[++faccnt]=x/i;
	}
}
inline void write(ll X)
{
	if(X>9) write(X/10);
	putchar(X%10+'0');
}
int main()
{
	scanf("%lld%lld",&n,&k);
	tmp=k*(k+1)/2,sum=n;
	if(tmp>n)
	{
		puts("-1");
		return 0;
	}
	factor(n);
	sort(fac+1,fac+faccnt+1);
	n/=*lower_bound(fac+1,fac+faccnt+1,tmp);
	for(register int i=1;i<k;++i)
		tp+=n,write(tp),putchar(' '),sum-=tp;
	printf("%lld\n",sum);
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#define ll long long
#define rg register
using namespace std;
inline ll read(){
	rg ll x=0; rg char c=getchar();
	while(c<='0'||c>'9') c=getchar();
	while(c>'0'&&c<'9') x=(x<<1)+(x<<3)+c-'0',c=getchar();
	return x;
}
ll n,k,ans;
inline bool check(ll val){
	return (k*(k+1)>>1)<=(n/val);
}
signed main(){
	n=read(); k=read();
	if(k==1) printf("%lld\n",n)&0;
	if((k*(k+1)>>1)>n) return puts("-1")&0;
	for(rg ll i=1;i*i<=n;++i){
		if(n%i!=0) continue;
		if(check(i)) ans=max(ans,i);
		if(check(n/i)) ans=max(ans,n/i);
	}
	if(ans==0) return puts("-1")&0;
	for(rg ll i=1;i<k;++i) printf("%lld ",ans*i);
	return printf("%lld\n",n-((ans*k*(k-1))>>1))&0;
}


// luogu-judger-enable-o2
#include<bits/stdc++.h>
#include<cctype>
#pragma GCC optimize(2)

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a),putchar('\n')

#define ll long long
#define New ll

using namespace std;

namespace IO_Optimization
{

	inline New read()
	{
	    New X = 0,w = 0;
		char ch = 0;

		while(!isdigit(ch))
		{
			w |= ch == '-';
			ch=getchar();
		}
	    while(isdigit(ch))
		{
			X = (X << 3) + (X << 1) + (ch ^ 48);
			ch = getchar();
		}
	    return w ? -X : X;
	}

	inline void write(New x)
	{
	     if(x < 0) putchar('-'),x = -x;
	     if(x > 9) write(x / 10);
	     putchar(x % 10 + '0');
	}
}
using namespace IO_Optimization;

New n,k,GCD,ans;

inline bool check(New now){
	return k * (k + 1) / 2 <= (n / now);
}

main(){
    in(n),in(k);

    for(New i = 1;i * i <= n; i++) {
        if(n % i != 0)
			continue;

		New dis = n / i;

        if(check(i)) {
        	if(GCD < i){
        		GCD = i;
			}
		}
        if(check(dis)) {
			if(GCD < dis){
				GCD = dis;
			}
		}
    }

    if(!GCD) {
    	puts("-1");
		exit(0);
	}

    for(New i = 1;i < k; i++){
    	out(i * GCD),putchar(' ');
    	ans += i * GCD;
	}

    out(n - ans);
    return 0;
}


#include<algorithm>
#include<stdio.h>
#define ll long long
#define rg register
using namespace std;
inline ll read(ll &T)
{
	T=0;char ssd=getchar();
	while(ssd<'0'||ssd>'9')ssd=getchar();
	while(ssd>='0'&&ssd<='9')T=(T<<3)+(T<<1)+(ssd-'0'),ssd=getchar();
}
int main()
{
	ll ans=0,n,k,left=1,right,k2;
	scanf("%lld %lld",&n,&k2);
	k=k2*(k2+1)/2,right=n+1;
	while(left<=right)
	{
		ll mid=(left+right)>>1;
		if(mid>n/k)right=mid-1;
		else left=mid+1,ans=mid;
	}
	if(n<k)puts("-1");
	else
	{
		for(ll u=1;u<k2;u+=1)printf("%lld ",u*ans);
		printf("%lld",ans*(n/ans-k+k2));
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#define clr(x) memset(x,0,sizeof(x))
#define clr_max(x) memset(x,0x3f3f3f3f,sizeof(x))
#define LL long long
using namespace std;
LL a[100010];
int main()
{
	LL n,m,k,maxn,sum;
	scanf("%I64d%I64d",&n,&k);
	if(k>43720 || (1+k)*k/2>n)
	{
		printf("-1\n");
		return 0;
	}
	maxn=1;
	for(LL i=1;i*i<=n;i++)
	{
		if(n%i==0 && n/i>=(1+k)*k/2)
		{
			maxn=max(maxn,i);
		}
		if(n%(n/i)==0 && i>=(1+k)*k/2)
		{
			maxn=max(maxn,n/i);
		}
	}
	n/=maxn;
	n-=(1+k)*k/2;
	for(int i=1;i<=k;i++)
	{
		a[i]=1;
	}
	for(int i=1;i<=k;i++)
	{
		a[i]+=n/(k-i+1);
		n=n%(k-i+1);
		if(n==0)
			break;
	}
	sum=0;
	for(int i=1;i<=k;i++)
	{
		sum+=a[i];
		printf("%I64d ",sum*maxn);
	}
	printf("\n");
	return 0;
 }


#include<cstdio>
#include<iostream>
#include<cstring>
#define clr(x) memset(x,0,sizeof(x))
#define clr_max(x) memset(x,0x3f3f3f3f,sizeof(x))
#define LL long long
using namespace std;
LL a[100010];
int main()
{
	LL n,m,k,maxn,sum;
	scanf("%I64d%I64d",&n,&k);
	if(k>43720 || (1+k)*k/2>n)
	{
		printf("-1\n");
		return 0;
	}
	maxn=1;
	for(LL i=1;i*i<=n;i++)
	{
		if(n%i==0 && n/i>(1+k)*k/2)
		{
			maxn=max(maxn,i);
		}
		if(n%(n/i)==0 && i>(1+k)*k/2)
		{
			maxn=max(maxn,n/i);
		}
	}
	n/=maxn;
	n-=(1+k)*k/2;
	for(int i=1;i<=k;i++)
	{
		a[i]=1;
	}
	for(int i=1;i<=k;i++)
	{
		a[i]+=n/(k-i+1);
		n=n%(k-i+1);
		if(n==0)
			break;
	}
	sum=0;
	for(int i=1;i<=k;i++)
	{
		sum+=a[i];
		printf("%I64d ",sum*maxn);
	}
	printf("\n");
	return 0;
 }


#include<cstdio>
#include<iostream>
#include<cstring>
#define clr(x) memset(x,0,sizeof(x))
#define clr_max(x) memset(x,0x3f3f3f3f,sizeof(x))
#define LL long long
using namespace std;
LL a[100010];
int main()
{
	LL n,m,k,maxn,sum;
	scanf("%I64d%I64d",&n,&k);
	if(k>43720 || (1+k)*k/2>n)
	{
		printf("-1\n");
		return 0;
	}
	maxn=1;
	for(LL i=1;i*i<=n;i++)
	{
		if(n%i==0 && n/i>=(1+k)*k/2)
		{
			maxn=max(maxn,i);
			printf("%d\n",i);
		}
		if(n%(n/i)==0 && i>=(1+k)*k/2)
		{
			maxn=max(maxn,n/i);
			printf("%d\n",i);
		}
	}
	n/=maxn;
	n-=(1+k)*k/2;
	for(int i=1;i<=k;i++)
	{
		a[i]=1;
	}
	for(int i=1;i<=k;i++)
	{
		a[i]+=n/(k-i+1);
		n=n%(k-i+1);
		if(n==0)
			break;
	}
	sum=0;
	for(int i=1;i<=k;i++)
	{
		sum+=a[i];
		printf("%I64d ",sum*maxn);
	}
	printf("\n");
	return 0;
 }


#include<cstdio>
#include<iostream>
#include<cstring>
#define clr(x) memset(x,0,sizeof(x))
#define clr_max(x) memset(x,0x3f3f3f3f,sizeof(x))
#define LL long long
using namespace std;
LL a[100010];
int main()
{
	LL n,m,k,maxn,sum;
	scanf("%I64d%I64d",&n,&k);
	if(k>43720 || (1+k)*k/2>n)
	{
		printf("-1\n");
		return 0;
	}
	maxn=1;
	for(LL i=1;i*i<=n;i++)
	{
		if(n%i==0 && n/i>(1+k)*k/2)
		{
			maxn=max(maxn,i);
		}
		if(n%(n/i)==0 && i>(1+k)*k/2)
		{
			maxn=max(maxn,i);
		}
	}
	n/=maxn;
	n-=(1+k)*k/2;
	for(int i=1;i<=k;i++)
	{
		a[i]=1;
	}
	for(int i=1;i<=k;i++)
	{
		a[i]+=n/(k-i+1);
		n=n%(k-i+1);
		if(n==0)
			break;
	}
	sum=0;
	for(int i=1;i<=k;i++)
	{
		sum+=a[i];
		printf("%I64d ",sum*maxn);
	}
	printf("\n");
	return 0;
 }


#include<cstdio>
#include<iostream>
#include<cstring>
#define clr(x) memset(x,0,sizeof(x))
#define clr_max(x) memset(x,0x3f3f3f3f,sizeof(x))
#define LL long long
using namespace std;
LL a[100010];
int main()
{
	LL n,m,k,maxn,sum;
	scanf("%I64d%I64d",&n,&k);
	if(k>43720 || (1+k)*k>n)
	{
		printf("-1\n");
		return 0;
	}
	maxn=1;
	for(LL i=1;i*i<=n;i++)
	{
		if(n%i==0 && n/i>(1+k)*k/2)
		{
			maxn=max(maxn,i);
		}
		if(n%(n/i)==0 && i>(1+k)*k/2)
		{
			maxn=max(maxn,i);
		}
	}
	n/=maxn;
	n-=(1+k)*k/2;
	for(int i=1;i<=k;i++)
	{
		a[i]=1;
	}
	for(int i=1;i<=k;i++)
	{
		a[i]+=n/(k-i+1);
		n=n%(k-i+1);
		if(n==0)
			break;
	}
	sum=0;
	for(int i=1;i<=k;i++)
	{
		sum+=a[i];
		printf("%I64d ",sum*maxn);
	}
	printf("\n");
	return 0;
 }


#include<cstdio>
#include<iostream>
#include<cstring>
#define clr(x) memset(x,0,sizeof(x))
#define clr_max(x) memset(x,0x3f3f3f3f,sizeof(x))
#define LL long long
using namespace std;
LL a[1000010];
LL max(LL a,LL b)
{
	return a>b?a:b;
}
int main()
{
	LL n,m,k,maxn,sum;
	scanf("%I64d%I64d",&n,&k);
	if(k>316227 || (1+k)*k/2>n)
	{
		printf("-1\n");
		return 0;
	}
	maxn=1;
	for(LL i=1;i*i<=n;i++)
	{
		if(n%i==0 && n/i>=(1+k)*k/2)
		{
			maxn=max(maxn,i);
		}
		if(n%(n/i)==0 && i>=(1+k)*k/2)
		{
			maxn=max(maxn,n/i);
		}
	}
	n/=maxn;
	n-=(1+k)*k/2;
	for(int i=1;i<=k;i++)
	{
		a[i]=1;
	}
	for(LL i=1;i<=k;i++)
	{
		a[i]+=n/(k-i+1);
		n=n%(k-i+1);
		if(n==0)
			break;
	}
	sum=0;
	for(int i=1;i<=k;i++)
	{
		sum+=a[i];
		printf("%I64d ",sum*maxn);
	}
	printf("\n");
	return 0;
 }


#include<cstdio>
#include<iostream>
#include<cstring>
#define clr(x) memset(x,0,sizeof(x))
#define clr_max(x) memset(x,0x3f3f3f3f,sizeof(x))
#define LL long long
using namespace std;
LL a[100010];
int main()
{
	LL n,m,k,maxn,sum;
	scanf("%I64d%I64d",&n,&k);
	if(k>316227 || (1+k)*k/2>n)
	{
		printf("-1\n");
		return 0;
	}
	maxn=1;
	for(LL i=1;i*i<=n;i++)
	{
		if(n%i==0 && n/i>=(1+k)*k/2)
		{
			maxn=max(maxn,i);
		}
		if(n%(n/i)==0 && i>=(1+k)*k/2)
		{
			maxn=max(maxn,n/i);
		}
	}
	n/=maxn;
	n-=(1+k)*k/2;
	for(int i=1;i<=k;i++)
	{
		a[i]=1;
	}
	for(int i=1;i<=k;i++)
	{
		a[i]+=n/(k-i+1);
		n=n%(k-i+1);
		if(n==0)
			break;
	}
	sum=0;
	for(int i=1;i<=k;i++)
	{
		sum+=a[i];
		printf("%I64d ",sum*maxn);
	}
	printf("\n");
	return 0;
 }


#include<cstdio>
#include<iostream>
#include<cstring>
#define clr(x) memset(x,0,sizeof(x))
#define clr_max(x) memset(x,0x3f3f3f3f,sizeof(x))
#define LL long long
using namespace std;
LL a[100010];
int main()
{
	LL n,m,k,maxn,sum;
	scanf("%lld%lld",&n,&k);
	if(k>43720 || (1+k)*k>n)
	{
		printf("-1\n");
		return 0;
	}
	maxn=1;
	for(LL i=1;i*i<=n;i++)
	{
		if(n%i==0 && n/i>(1+k)*k/2)
		{
			maxn=max(maxn,i);
		}
		if(n%(n/i)==0 && i>(1+k)*k/2)
		{
			maxn=max(maxn,i);
		}
	}
	n/=maxn;
	n-=(1+k)*k/2;
	for(int i=1;i<=k;i++)
	{
		a[i]=1;
	}
	for(int i=1;i<=k;i++)
	{
		a[i]+=n/(k-i+1);
		n=n%(k-i+1);
		if(n==0)
			break;
	}
	sum=0;
	for(int i=1;i<=k;i++)
	{
		sum+=a[i];
		printf("%lld ",sum*maxn);
	}
	printf("\n");
	return 0;
 }


#include <bits/stdc++.h>

using namespace std;

int main(){
    long n, k; scanf("%ld %ld", &n, &k);

    vector <long> d = {};
    for(int i=1; i<=sqrt(n)+1; i++){

        if(n % i == 0){
            d.push_back(i); d.push_back(n / i);
        }
    }

    bool found = false;
    for(int i=d.size()-1; i>=0; i--){

        long sum = d[i]*(k*(k-1)/2);
        if(n - sum > (k-1)*d[i]){

            if(n == 2 && k == 10000000000)
                cout << n << " " << sum << " " << n - sum << " " << (k-1)*d[i] << endl;
            found = true;

            for(int j=1; j<k; j++)
                printf("%ld ", j*d[i]);
            printf("%ld\n", n-sum);
            break;
        }
    }

    if(found == false) cout << -1 << endl;
    return 0;
}


#include <bits/stdc++.h>

typedef unsigned long long ll;
using namespace std;

int main(){

    ll n, k; scanf("%lld %lld\n", &n, &k);

    set <int> d;

    for(int i=1; i<=(int)sqrt(n)+1; i++){
        if(n % i == 0){
            d.insert(i);
            d.insert(n / i);
        }
    }

    set<int>::reverse_iterator it = d.rbegin();

    while(it != d.rend()){
        ll cnt = (*it) * (k*(k-1) / 2);
        long long remain = n - cnt;
        if(remain <= 0 || remain <= (*it) * (k-1)){
            it++;
            continue;
        }
        for(int i=1; i<k; i++)
            printf("%lld ", 1LL * (*it) * i);
        printf("%lld\n", remain);
        return 0;
    }

    cout << "-1" << endl;
    return 0;
}


#include<bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){

    ll n, k; scanf("%lld %lld\n", &n, &k);

    set <ll> d;

    for(int i=1; i<=sqrt(n) + 1; i++){
        if(n % i == 0){
            d.insert(i); d.insert(n / i);
        }
    }

    for(set<ll>::reverse_iterator it = d.rbegin(); it != d.rend(); it++){
        ll elem = *it;
        if(n - (elem * (k*(k-1)>>1)) > elem*(k - 1)) {

            for(int i=1; i<k; i++)
                printf("%lld ", i*elem);
            printf("%lld\n", n - (elem * (k*(k-1)>>1)));
            return 0;
        }
    }
    puts("-1");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
    long long n, k; scanf("%lld %lld", &n, &k);

    set <long long> dd;
    for(int i=1; i<=sqrt(n)+1; i++){

        if(n % i == 0){
            dd.insert(i); dd.insert(n / i);
        }
    }

    vector <long long> d(dd.begin(), dd.end());
    bool found = false;
    for(int i=d.size()-1; (i >= 0) && (found == false); i--){

        long long sum = d[i]*(k*(k-1)/2);
        if(n - sum > (k-1)*d[i]){

            found = true;

            for(int j=1; j<k; j++)
                printf("%lld ", j*d[i]);
            printf("%lld\n", n-sum);
        }
    }

    if(found == false) cout << -1 << endl;
    return 0;
}