#[allow(unused_macros)] // https://earthly.dev/blog/rust-macros/ macro_rules! exit_with_print { ($x: expr) => { println!("{}", $x); exit(0); }; } fn main() { let mut out = BufWriter::new(stdout().lock()); input! {t: usize} for _ in 0 .. t { input! {a: i64, b: i64, c: i64, x: i64, y: i64, z: i64} let posa = (b - a).abs() * y + (c - a).abs() * z; let posb = (b - a).abs() * x + (c - b).abs() * z; let posc = (c - a).abs() * x + (c - b).abs() * y; writeln!(out, "{} ", min(posa, min(posb, posc))).unwrap(); } } #[allow(unused_imports)] use { //ac_library::*, //itertools::Itertools, proconio::{fastout, input, marker::Bytes, marker::Chars, marker::Usize1}, //rustc_hash::{FxHashMap, FxHashSet}, std::{ cmp::{max, min, Reverse}, collections::{BTreeMap, BinaryHeap, VecDeque}, convert::TryInto, io::{self, stdout, BufRead, BufWriter, Write}, num::*, ops::BitXor, process::exit, }, };