use proconio::input; fn main() { input! { n: usize, _f: usize, abc: [[u32; n]; 3], } let abc = (0..n) .map(|i| [abc[0][i], abc[1][i], abc[2][i]]) .collect::<Vec<_>>(); let mut dp = vec![0u64; n + 2]; dp[n] = 1; let ans = abc .iter() .map(|x| { let mut swp = vec![0; n + 2]; for &x in x { if x == 0 { for i in 0..=n { swp[i] |= dp[i]; } } else { for i in 0..=n { assert_eq!(dp[i].wrapping_shl(x) & (dp[i + 1] >> (64 - x)), 0); swp[i] |= dp[i].wrapping_shl(x) ^ (dp[i + 1] >> (64 - x)); } } } dp = swp; dp.iter().map(|dp| dp.count_ones()).sum::<u32>() }) .collect::<Vec<_>>(); println!( "{}", ans.iter() .map(std::string::ToString::to_string) .collect::<Vec<_>>() .join("\n") ); }