include "stdafx.h"
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<mutex>
#include<stack>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
int w, h, x, n;
int pi = 3.1415926;
while (cin>>w>>h>>x>>n)
{
//判断每次弹出的小球是右侧还是左侧
//记录正在操作的边
int left = 0;
int right = 0;
int up = 0;
int down = 0;
while (n!=0)
{
n--;
while (down!=1)
{
if ((w - x) == h)
{
//cout << x << " " << endl;
down = 1;
left = 0;
right = 0;
up = 0;
}
else if ((w - x) < h) //碰到右面
{
if (down == 1)
{
down = 0;
left = 0;
right = 1;
up = 0;
}
else if (right==1)
{
down = 0;
left = 0;
right = 0;
up = 1;
}
else if (up == 1)
{
down = 0;
left = 1;
right = 0;
up = 0;
}
else
{
down = 1;
left = 0;
right = 0;
up = 0;
}
x = w - x;
int temp = w;
w = h;
h = temp;
}
else//碰到上面面
{
if (down == 1)
{
down = 0;
left = 0;
right = 0;
up = 1;
}
else if (right == 1)
{
down = 0;
left = 1;
right = 0;
up = 0;
}
else if (up == 1)
{
down = 1;
left = 0;
right = 0;
up = 0;
}
else
{
down = 0;
left = 0;
right = 1;
up = 0;
}
x = x + h;
int temp = w;
w = h;
h = temp;
}
}
if (n != 0)
{
cout << x<<" ";
}
}
cout <<x;
}
return 0;
}