import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); long a = sc.nextLong(); long b = sc.nextLong(); long[] x = new long[7]; x[0] = sc.nextLong(); long n = sc.nextLong(); sc.close(); long m = 1L << 32; for (int i = 1; i < x.length; i++) { x[i] = a * x[i - 1] % m + b; x[i] %= m; } for (int i = 1; i < x.length; i++) { x[i]++; } if (x[1] % 2 == 1) { System.out.println(n / 2 + " 0"); } else { System.out.println("0 " + n / 2); } } }