#include <bits/stdc++.h>
using namespace std;
const int N = (int)(5e5), MOD = (int)(1e9) + 7;
int dp[2][N + 1], sum[N + 1];
void solve() {
  int n, a, b, k;
  scanf("%d %d %d %d", &n, &a, &b, &k);
  dp[0][a] = 1;
  for (int i = a; i <= n; i++) sum[i] = 1;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      if (j == b) continue;
      dp[i % 2][j] = ((j < b ? sum[j + (b - j - 1) / 2]
                             : (sum[n] - sum[b + (j - b) / 2] + MOD) % MOD) -
                      dp[1 - i % 2][j] + MOD) %
                     MOD;
    }
    for (int j = 1; j <= n; j++) sum[j] = (sum[j - 1] + dp[i % 2][j]) % MOD;
  }
  printf("%d\n", sum[n]);
}
int main() {
  solve();
  return 0;
}
