https://www.acmicpc.net/problem/10158
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
int w=s.nextInt();
int h=s.nextInt();
int p=s.nextInt();
int q=s.nextInt();
int t=s.nextInt();
int x=t%(2*w);
int y=t%(2*h);
if(x<=w-p) p+=x;
else if(x<=2*w-p) p=w-(x-w+p);
else p=x-2*w+p;
if(y<=h-q) q+=y;
else if(y<=2*h-q) q=h-(y-h+q);
else q=y-2*h+q;
System.out.format("%d %d",p,q);
}
}