using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray(); static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray(); static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray(); public static void Main() { Solve(); } static void Solve() { var t = NN; var ans = new long[t]; for (var u = 0; u < t; ++u) { var c = NList; ans[u] = Eq(c[0], c[1], c[2], c[3], c[4], c[5]); } WriteLine(string.Join("\n", ans)); } static long Eq(long a, long b, long c, long x, long y, long z) { if (x >= y && x >= z) { return Math.Abs(a - b) * y + Math.Abs(a - c) * z; } if (x <= y && y >= z) { return Math.Abs(a - b) * x + Math.Abs(b - c) * z; } return Math.Abs(a - c) * x + Math.Abs(b - c) * y; } }