Sunyoung's second anniversary with her boyfriend is close. She wants to give him something special. He likes trees a lot, but Sunyoung thinks a tree is too big to hand over as a gift, so she settled on flowers.
Sunyoung believes that every flower has one vase volume that suits it best. She opened an online store to buy a vase, and each listing carries a photo and an outline function. Write a program that finds the vase closest to the volume she wants.
The outline of a vase is the function f(x)=ae−x2+bx. Here x is the vertical distance measured from the bottom of the vase, and the vase is the solid obtained by rotating this curve around the x axis. The height of the vase is h, so its volume is
V=π∫0hf(x)2dx
Two different vases differ in volume by at least 10−4. The gap to the volume Sunyoung wants also differs from vase to vase by at least 10−4, so exactly one vase is the answer.
The first line contains the volume V that Sunyoung wants and the number of vases N listed in the store. (1<V≤105, 0<N≤5)
Each of the next N lines contains a, b, and h, which determine the outline function of one vase. (1≤a,b,h≤10)
V, a, b, and h are real numbers and are sometimes written without a decimal point.
A vase with a=1, b=2, h=2 has volume 34.72348, and a vase with a=2, b=1, h=2 has volume 21.77966.
Print the index of the vase whose volume differs least from the volume Sunyoung wants. The first vase has index 0.