{"trustable":false,"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":" 有n种珍珠,给出每种要买的数量和价格。按价格升序输入;现在有两种购买的方法,第一,如果单买一种,需要多买10个。第二 ,如果买连续的珍珠,也只需要多出10个,但是全部要按最高价格。\n假设:\n假设有二个等级的珍珠:价值10的要买5个,价值20的要买100个,你可以分开买要花费(5+10)*10+(100+10)*20\u003d2350 一次买(5+100+10)*20\u003d2300"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains the number of test cases. Each test case starts with a line containing the number of categories c (1 \u0026lt;\u003d c \u0026lt;\u003d 100). Then, c lines follow, each with two numbers ai and pi. The first of these numbers is the number of pearls ai needed in a class (1 \u0026lt;\u003d ai \u0026lt;\u003d 1000). The second number is the price per pearl pi in that class (1 \u0026lt;\u003d pi \u0026lt;\u003d 1000). The qualities of the classes (and so the prices) are given in ascending order. All numbers in the input are integers. \n\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case a single line containing a single number: the lowest possible price needed to buy everything on the list. \n\u003cbr\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e2\n2\n100 1\n100 2\n3\n1 10\n1 11\n100 12\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e330\n1344\u003c/pre\u003e"}}]}