use ez_input::{Scanner, ScannerExt};
fn main() {
let mut sc = Scanner::stdin();
let t: i32 = sc.next();
for case in 1..=t {
let n: usize = sc.next();
let m: usize = sc.next();
let arr: Vec<i32> = sc.next_vec(n);
let matrix: Vec<Vec<i32>> = (0..n)
.map(|_| (0..m).map(|_| sc.next()).collect())
.collect();
let sum: i32 = sc.iter::<i32>().take(m).sum();
println!("Case #{}: {} {} {}", case, arr[0], matrix[0][0], sum);
}
}