Safe Zone

No attempts yetTime limit1sMemory limit256 MB

Problem

Saruman's army has laid siege to Helm's Deep and is firing volley after volley of arrows at its walls. The Rohirrim have shields for only one stretch of the wall. You are a soldier in King Theoden's army, and you have to reach that stretch before the next volley lands.

From left to right the wall segments are numbered 00 through N1N-1, and you are standing on segment JJ. The shields cover segments PP through QQ. Before the next volley you have time for exactly KK steps, and each step moves you one segment left or one segment right. The wall shakes too hard for you to stand still.

Count the sequences of KK steps that leave you on a segment between PP and QQ. Two sequences that differ in any step are counted separately.

Input

The input holds several test cases. Each test case is one line with NN, PP, QQ, JJ, and KK separated by spaces. NN is the length of the wall, PP and QQ are the ends of the safe zone, JJ is the starting position, and KK is the number of steps. A line whose NN is 00 marks the end of the input and produces no output.

You cannot walk off the end of the wall. On segment 00 you must step right, and on segment N1N-1 you must step left.

  • 2N10002 \le N \le 1000
  • 0PQN10 \le P \le Q \le N-1
  • 0JN10 \le J \le N-1
  • 1K601 \le K \le 60
  • There are at most 100 test cases.
  • The last line is always 0 0 0 0 0.

Output

For each test case, print on its own line the number of ways to end up in the safe zone after KK steps. The answer fits in a signed 64-bit integer.