fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let mut v: Vec = s.split_whitespace().flat_map(str::parse).collect(); let (mut t, mut a) = (vec![0, 0], vec![0, 0]); for _ in 0..v[3] { v[2] = (v[0] * v[2] + v[1]) % 2u64.pow(32); t[0] += v[2] % 6 + 1; t[1] += if t[0] % 2 == 0 { 1 } else { 0 }; v[2] = (v[0] * v[2] + v[1]) % 2u64.pow(32); a[0] += v[2] % 6 + 1; a[1] += if a[0] % 2 == 0 { 1 } else { 0 }; } println!("{} {}", t[1].min(v[3] - t[1]), a[1].min(v[3] - a[1])); }