#![allow(unused_must_use, non_snake_case)] use std::io::{stdin, stdout, BufWriter, Write}; fn main() { let mut scan = Scanner::default(); macro_rules! input { ($T: ty) => { scan.next::<$T>() }; ($T: ty, $N: expr) => { (0..$N).map(|_| scan.next::<$T>()).collect::>() }; } let T = input!(usize); let N = input!(usize); let mut M = input!(usize); let mut S = vec![]; let mut P = vec![]; let mut R = vec![]; // g >= 3 を最初にやったら M = 0 になる :( let g = 2; { let out = &mut BufWriter::new(stdout()); writeln!(out, "2 {}", g); } { M = { let r = input!(isize); assert!(r != -1); r as usize }; S = input!(usize, N); P = input!(isize, N); R = input!(usize, N); } for _ in 1..T { let C = M / 500; let C_half = C / 2; // output { let out = &mut BufWriter::new(stdout()); let sum_of_weight = P.iter().map(|&p| if p >= 0 { p } else { 0 }).sum::(); // assert!(sum_of_weight > 0); let L = (0..N) .map(|i| { C_half / N + C_half * (if P[i] > 0 { P[i] } else { 0 }) as usize / sum_of_weight as usize }) .collect::>(); writeln!( out, "1 {}", L.iter() .map(|x| x.to_string()) .collect::>() .join(" ") ); } // input { M = { let r = input!(isize); assert!(r != -1); r as usize }; S = input!(usize, N); P = input!(isize, N); R = input!(usize, N); } } } #[derive(Default)] struct Scanner { buffer: Vec, } impl Scanner { fn next(&mut self) -> T { loop { if let Some(token) = self.buffer.pop() { return token.parse().ok().expect("Failed parse"); } let mut input = String::new(); stdin().read_line(&mut input).expect("Failed read"); self.buffer = input.split_whitespace().rev().map(String::from).collect(); } } }