// Arup Guha
// 3/11/2014
// Solution to 2014 FHSPS Playoff Problem: Movie Trip(trip)

import java.util.*;

public class trip {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Go through each case.
		for (int loop=0; loop<numCases; loop++) {

			// Read in data.
			double aPrice = stdin.nextDouble();
			double cPrice = stdin.nextDouble();
			int numA = stdin.nextInt();
			int numC = stdin.nextInt();

			// Output result.
			System.out.printf("%.2f\n", numA*aPrice+numC*cPrice);
		}
	}
}