{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e在本题中,我们只有两种方法计算两个$n\\times n$的矩阵的乘积,第一种为定义法,需要$n^3$次乘法和$(n-1)n^2$次加法。第二种为Strassen分治法,仅当$n$为偶数时可以使用,需要$18(n/2)^2$次加法以及再计算$7$次大小为$(n/2)\\times(n/2)$的矩阵的乘积。这$7$次更小矩阵的乘积也可以选择两种方法之一计算。现假设计算机计算一次加法需要$a$单位时间,计算一次乘法需要$b$单位时间,其他任何操作不花费时间,问计算两个$n\\times n$的矩阵的乘积至少需要多少时间。输出答案模$10^9+7$的余数。\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"第一行一个正整数$t$表示数据组数($1\\le t \\le 20$)。\u003cbr\u003e每组数据包含一行三个正整数$n$,$a$,$b$($1\\le n\\le 2^{32}$,$n$是$2$的幂,$1\\le a\\le 10^9$,$1\\le b\\le 10^9$)。"}},{"title":"Output","value":{"format":"HTML","content":"每组数据输出一行,包含一个整数表示答案模$10^9+7$的余数。"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n16 1 1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e7872\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}