import java.io.*; import java.math.*; import java.lang.*; public class ame { public static void main(String args[]) { try { new ame(); } catch (Exception e) {e.printStackTrace();} } public ame() throws Exception { BufferedReader br = new BufferedReader(new FileReader(new File("ame.in"))); int dataSets = Integer.parseInt(br.readLine()); // up to 30 stages float m[] = new float[30]; float t[] = new float[30]; float F[] = new float[30]; //int n[] = new int[10000]; //int total = 0; for(int dataSet = 0; dataSet < dataSets; dataSet++) { System.out.println("Data Set " + (dataSet + 1) + ":"); //total = 0; String nums[] = br.readLine().split(" "); //total weight float weight = Float.parseFloat(nums[1]); //get all stages for(int a = 0; a < Integer.parseInt(nums[0]); a++) { //float thism; //float thist; //float thisF; String stage[] = br.readLine().split(" "); m[a] = Float.parseFloat(stage[0]); t[a] = Float.parseFloat(stage[1]); F[a] = Float.parseFloat(stage[2]); //System.out.println("read F " + F[a]); weight += m[a]; } //System.out.println("weight0 " + weight); float v = 0; float h = 0; final float g = 9.81f; for(int c = 0; c < Integer.parseInt(nums[0]); c++) { float thisa; //System.out.println("dividing F " + F[c] + " / " + weight); //thisa = (F[c] - g) / weight; thisa = F[c] / weight; //System.out.println("accelerating(ps) at " + thisa); thisa = thisa - g; // subtract effect of earth's gravity downward //System.out.println("accelerating at " + thisa); //System.out.println("t[c] " + t[c]); //System.out.println("v " + v + " , a " + thisa); h += v * t[c] + 0.5f * thisa * t[c] * t[c]; //System.out.println("h = " + h); v += thisa * t[c]; weight -= m[c]; } System.out.println((new java.text.DecimalFormat("#.##")).format(h)); } } }