https://www.acmicpc.net/problem/10158
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine()," ");
// 넓이
int W = Integer.parseInt(st.nextToken());
// 높이
int H = Integer.parseInt(st.nextToken());
// W * H 의 격자 공간
st = new StringTokenizer(br.readLine()," ");
// 현재 위치
int P = Integer.parseInt(st.nextToken());
// 현재 위치
int Q = Integer.parseInt(st.nextToken());
st = new StringTokenizer(br.readLine());
// 계산할 시간
int T = Integer.parseInt(st.nextToken());
int currentX = (P+T) % (2 * W);
int currentY = (Q+T) % (2 * H);
if(currentX > W) currentX = 2*W - currentX;
if(currentY > H) currentY = 2*H - currentY;
System.out.println(currentX+" "+currentY);
}
}