#include <bits/stdc++.h>
int dp[5001][5001];
int qs[5001][5001];
int main() {
  while (true) {
    int n, a, b, k;
    scanf("%d%d%d%d", &n, &a, &b, &k);
    if (n == 0) break;
    int size;
    int ix;
    if (a > b) {
      size = n - b;
      ix = a - b - 1;
    } else {
      size = b - 1;
      ix = b - a - 1;
    }
    dp[0][0] = 1;
    qs[0][0] = 1;
    for (int i = 1; i < size; ++i) {
      dp[0][i] = 1;
      qs[0][i] = i + 1;
    }
    for (int r = 1; r < k; ++r) {
      for (int i = 0; i < size; ++i) {
        dp[r][i] = qs[r - 1][std::min(size - 1, i + i)] - dp[r - 1][i];
        if (dp[r][i] >= 1000000007) dp[r][i] -= 1000000007;
        if (dp[r][i] < 0) dp[r][i] += 1000000007;
      }
      qs[r][0] = dp[r][0];
      for (int i = 1; i < size; ++i) {
        qs[r][i] = qs[r][i - 1] + dp[r][i];
        if (qs[r][i] >= 1000000007) qs[r][i] -= 1000000007;
        if (dp[r][i] < 0) dp[r][i] += 1000000007;
      }
    }
    dp[k][ix] = qs[k - 1][std::min(size - 1, ix + ix)] - dp[k - 1][ix];
    if (dp[k][ix] >= 1000000007) dp[k][ix] -= 1000000007;
    if (dp[k][ix] < 0) dp[k][ix] += 1000000007;
    printf("%d\n", dp[k][ix]);
    break;
  }
  return 0;
}
