#include #define M 1000000007 using namespace std; typedef long long ll; int T; ll n,a,b,dp[32],N; int main(){ scanf("%d",&T); while (T--){ scanf("%I64d%I64d%I64d",&n,&a,&b); N=0; while (n>1) N++,n>>=1; dp[0]=b; for (int i=1;i<=5;i++){ dp[i]=min(dp[i-1]*7+(a<<(2*i-2))*18,(b<<(3*i))+((a*((1<