fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let _n: usize = n.trim().parse().unwrap(); let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let a: Vec = a.trim().split_whitespace() .map(|x| x.parse().unwrap()).collect(); let mut b = String::new(); std::io::stdin().read_line(&mut b).ok(); let b: Vec = b.trim().split_whitespace() .map(|x| x.parse().unwrap()).collect(); let mut c = String::new(); std::io::stdin().read_line(&mut c).ok(); let c: Vec = c.trim().split_whitespace() .map(|x| x.parse().unwrap()).collect(); let an = a.iter().filter(|&&x| x % 3 != 0).count(); let bn = b.iter().filter(|&&x| x % 3 != 0).count(); let cn = c.iter().filter(|&&x| x % 3 != 0).count(); println!("{}", an * bn * cn); }