// 制約の確認 import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc=new Scanner(System.in); long a=sc.nextLong(); long b=sc.nextLong(); long x0=sc.nextLong(); long N=sc.nextLong(); if(!(0<=a&&0<=b&&0<=x0&&0<=N&&a<(1L<<32)&&b<(1L<<32)&&x0<(1L<<32)&&N<(1L<<32)))throw new AssertionError(); if(!(a%4==1&&b%2==1))throw new AssertionError(); long x1=(a*x0+b)%6+1; System.out.println(x1%2==0?(0+" "+N/2):(N/2+" "+0)); } void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));} }