{"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":"\u003cdiv\u003e\n The aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught in the end, often because they become too greedy. He has decided to work in the lucrative business of bank robbery only for a short while, before retiring to a comfortable job at a university.\n \u003cbr\u003e \n \u003cbr\u003e \n \u003cimg src\u003d\"http://7xjob4.com1.z0.glb.clouddn.com/931cc59be308ad18cd98b5c8caec6454\"\u003e \n \u003cbr\u003e For a few months now, Roy has been assessing the security of various banks and the amount of cash they hold. He wants to make a calculated risk, and grab as much money as possible.\n \u003cbr\u003e \n \u003cbr\u003e \n \u003cbr\u003e His mother, Ola, has decided upon a tolerable probability of getting caught. She feels that he is safe enough if the banks he robs together give a probability less than this.\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e The first line of input gives T, the number of cases. For each scenario, the first line of input gives a floating point number P, the probability Roy needs to be below, and an integer N, the number of banks he has plans for. Then follow N lines, where line j gives an integer \u003cspan\u003eMj\u003c/span\u003e and a floating point number \u003cspan\u003ePj\u003c/span\u003e .\u003cbr\u003e Bank j contains \u003cspan\u003eMj\u003c/span\u003e millions, and the probability of getting caught from robbing it is \u003cspan\u003ePj\u003c/span\u003e .\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e For each test case, output a line with the maximum number of millions he can expect to get while the probability of getting caught is less than the limit set.\u003cbr\u003e \u003cbr\u003e Notes and Constraints\u003cbr\u003e 0 \u0026lt; T \u0026lt;\u003d 100\u003cbr\u003e 0.0 \u0026lt;\u003d P \u0026lt;\u003d 1.0\u003cbr\u003e 0 \u0026lt; N \u0026lt;\u003d 100\u003cbr\u003e 0 \u0026lt; \u003cspan\u003eMj\u003c/span\u003e \u0026lt;\u003d 100\u003cbr\u003e 0.0 \u0026lt;\u003d \u003cspan\u003ePj\u003c/span\u003e \u0026lt;\u003d 1.0\u003cbr\u003e A bank goes bankrupt if it is robbed, and you may assume that all probabilities are independent as the police have very low funds.\u003c/p\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e\r\n3\r\n0.04 3\r\n1 0.02\r\n2 0.03\r\n3 0.05\r\n0.06 3\r\n2 0.03\r\n2 0.03\r\n3 0.05\r\n0.10 3\r\n1 0.03\r\n2 0.02\r\n3 0.05\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e\r\n2\r\n4\r\n6\u003c/pre\u003e"}}]}