#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int N = 1e3 + 5;
const int mod = 100000007;
int n, s, a, b, up;
ll v;
int dp[2][N * (N + 1) / 2], now;
int ans;
int main()
{
	scanf("%d%d%d%d", &n, &s, &a, &b);
	dp[now][0] = 1;
	for (int i = 1; i < n; ++i) //只有n-1个增量
	{
		now = !now;
		up = i * (i + 1) / 2;
		for (int j = 0; j <= up; ++j) //01背包 容量 方案数
		{
			dp[now][j] = dp[!now][j];
			if (j >= i)
				dp[now][j] = (dp[now][j] + dp[!now][j - i]) % mod;
		}
	}
	for (int i = 0; i <= up; ++i) //s-i*a-(n*(n-1)/2-i)*b 是否被n整除
	{
		v = 1ll * s - 1ll * i * a + 1ll * (up - i) * b;
		if (v % n == 0)
			ans = (ans + dp[now][i]) % mod;
	}
	printf("%d\n", ans);
	return 0;
}