CodeEff/ECCO huggingface dataset:
# Original solution
while True:
    things = {}
    count = eval(input())
    if count == 0: break
    for i in range(count):
        fuga = input().split()
        things[fuga[0]] = int(fuga[1])
    for i in range(eval(input())):
        fuga = input().split()
        money =0
        for j in range(int(fuga[1])):
            hoge = things[fuga[j+2]] if fuga[j+2] in things else 0
            money+= hoge
        things[fuga[0]] = things[fuga[0]] if money > things[fuga[0]] else money
    ans = input()
    fin = things[ans] if ans in things else 0
    print(fin)

# Optimized solution
while True:
    things = {}
    count = eval(input())
    if count == 0: break
    for i in range(count):
        fuga = input().split()
        things[fuga[0]] = int(fuga[1])
    for i in range(eval(input())):
        fuga = input().split()
        money =0
        for j in range(int(fuga[1])):
            hoge = things[fuga[j+2]] if fuga[j+2] in things else 0
            money+= hoge
        things[fuga[0]] = things[fuga[0]] if money > things[fuga[0]] else money
    ans = input()
    print("%s"%(things[ans] if ans in things else "0"))
# Original solution
n,a,b,k=list(map(int,input().split()))
p=998244353
def getinv(n):
  inv=[0]*(n+1)
  for i in range(1,n+1):
    inv[i]=pow(i,p-2,p)
  return inv
def getnCr(n):
  inv=getinv(n)
  nCr=[0]*(n+1)
  nCr[0]=1
  for i in range(1,n+1):
    nCr[i]=(nCr[i-1]*(n-i+1)*inv[i])%p
  return nCr
def solve(n,a,b,k):
  ans=0
  nCr=getnCr(n)
  for i in range(n+1):
    if (k-a*i)<0 or (k-a*i)%b!=0:
      continue
    j=(k-a*i)//b
    if a*i+b*j==k and 0<=j<=n:
      ans+= nCr[i]*nCr[j]
      ans%=p
  return ans
print((solve(n,a,b,k)))

# Optimized solution
p=998244353
def getinv(n):
  inv = [0]*(n+1)
  #フェルマーの小定理より、i=1の時は1であることが分かる
  inv[1] = 1
  for i in range(2,n+1):
    #そのまま計算すると負になってしまうので、最後にmod pを取ることで正に戻す
    inv[i] = (-(p//i)*inv[p%i])%p
  return inv

def getCmb(n):
  #逆元を取得
  inv = getinv(n)
  #0 <= r <= n に対してnCrを求める
  nCr = [0]*(n+1)
  #r=0の時は、r-1が存在しないので与えておく
  nCr[0] = 1
  for i in range(1,n+1):
    #iで割る代わりにinv[i]をかけ、mod pを求める
    nCr[i] = (nCr[i-1]*(n-i+1)*inv[i])%p
  return nCr

def solve(n,a,b,k):
  nCr = getCmb(n)
  ans=0
  for i in range(n+1):
    #割り切れない時もあるが、その時は次の条件a*i+b*j==kで弾かれるので問題ない
    j = (k-a*i)//b
    #条件に一致するものを選ぶ。jの範囲に注意
    if a*i + b*j == k and 0<=j<=n:
      ans+= (nCr[i]*nCr[j])%p
      ans%= p
  return ans

n,a,b,k=list(map(int,input().split()))
print((solve(n,a,b,k)))
# Original solution
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 16 15:50:39 2019

@author: Yamazaki Kenichi
"""

N,A,B,K = list(map(int,input().split()))
mod = 998244353

T = []
R = K//A
for i in range(R+1):
    if i == 0:
        if K%B == 0 and K//B <= N:
            T.append([0,0,K//B,N-K%B])
        continue
    if (K - (A*i)) % B == 0:
        r = i
        b = (K - (A*i)) // B
        g = min(r,b)
        r,b = r-g, b-g
        while r+g+b <=N and g>=0:
            T.append([r,g,b,N-(r+g+b)])
            r,g,b = r+1,g-1,b+1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inv = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, N+1):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)

ans = 0
for c in T:
    ans += g1[N]*g2[c[0]]*g2[c[1]]*g2[c[2]]*g2[c[3]]%mod
print((ans%mod))


# Optimized solution
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 16 18:32:20 2019

@author: Yamazaki Kenichi
"""

N,A,B,K = list(map(int,input().split()))
mod = 998244353
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inv = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, N+1):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)
def a(r,g,b):
    return g1[N]*g2[r]*g2[g]*g2[b]*g2[N-r-g-b]%mod

ans = 0
R = K//A
for i in range(R+1):
    if i == 0:
        if K%B == 0 and K//B <= N:
            ans += a(0,0,K//B)
        continue
    if (K - (A*i)) % B == 0:
        r = i
        b = (K - (A*i)) // B
        g = min(r,b)
        r,b = r-g, b-g
        while r+g+b <=N and g>=0:
            ans += a(r,g,b)
            r,g,b = r+1,g-1,b+1
print((ans%mod))
# Original solution
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 16 18:32:20 2019

@author: Yamazaki Kenichi
"""

N,A,B,K = list(map(int,input().split()))
mod = 998244353
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inv = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, N+1):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)
def a(r,g,b):
    return g1[N]*g2[r]*g2[g]*g2[b]*g2[N-r-g-b]%mod

ans = 0
R = K//A
for i in range(R+1):
    if i == 0:
        if K%B == 0 and K//B <= N:
            ans += a(0,0,K//B)
        continue
    if (K - (A*i)) % B == 0:
        r = i
        b = (K - (A*i)) // B
        g = min(r,b)
        r,b = r-g, b-g
        while r+g+b <=N and g>=0:
            ans += a(r,g,b)
            r,g,b = r+1,g-1,b+1
print((ans%mod))


# Optimized solution
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 16 18:40:19 2019

@author: Yamazaki Kenichi
"""

N,A,B,K = list(map(int,input().split()))
mod = 998244353
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inv = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, N+1):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)
def a(r,b):
    return cmb(N,r,mod)*cmb(N,b,mod)
ans = 0
R = K//A
for i in range(R+1):
    if (K-A*i)%B == 0:
        ans += a(i,(K-A*i)//B) % mod
print((ans%mod))
# Original solution
N, A, B, K = list(map(int, input().split()))
maxAB = max(A, B)
minAB = min(A, B)
ans = 0


def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return fac[n] * finv[r] * finv[n-r] % mod


mod = 998244353  # 問題によって変える、ここは素数でないとうまく動かない
N_cmb = 0
N_cmb += N  # 入力の制約によって変えるところ、nCrの計算で欲しいnの最大値
fac = [1, 1]  # 階乗テーブル
finv = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for ZZZ in range(2, N_cmb + 1):
    fac.append((fac[-1] * ZZZ) % mod)
    inverse.append(mod-inverse[mod % ZZZ]*(mod//ZZZ) % mod)
    finv.append((finv[-1] * inverse[-1]) % mod)

for i in range(N+1):
    j = (K - maxAB * i) // minAB
    if (K - maxAB * i) % minAB == 0 and 0 <= j <= N:
        #print(i, j)
        for h in range(min(i, j)+1):
            if i + j - h <= N:
                #print(cmb(N, h), cmb(N - h, i - h), cmb(N - i, j - h))
                ans += ((cmb(N, h) * cmb(N - h, i - h)) %
                        mod) * cmb(N - i, j - h)
                ans %= mod
print(ans)


# Optimized solution
N, A, B, K = list(map(int, input().split()))
maxAB = max(A, B)
minAB = min(A, B)
ans = 0


def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return fac[n] * finv[r] * finv[n-r] % mod


mod = 998244353  # 問題によって変える、ここは素数でないとうまく動かない
N_cmb = 0
N_cmb += N  # 入力の制約によって変えるところ、nCrの計算で欲しいnの最大値
fac = [1, 1]  # 階乗テーブル
finv = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for ZZZ in range(2, N_cmb + 1):
    fac.append((fac[-1] * ZZZ) % mod)
    inverse.append(mod-inverse[mod % ZZZ]*(mod//ZZZ) % mod)
    finv.append((finv[-1] * inverse[-1]) % mod)

for i in range(min(N+1, K//maxAB+1)):
    j = (K - maxAB * i) // minAB
    if (K - maxAB * i) % minAB == 0 and 0 <= j <= N:
        #print(i, j)
        ans += cmb(N, i) * cmb(N, j) % mod
        ans %= mod
print(ans)
# Original solution
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 998244353

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

def comb(n,a,R):
    return (fact[n]*modinv2(fact[n-a]*fact[a],R))

def factinit(n,R):
    global fact
    fact = [1]*(n+1)
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%R


n,a,b,k = inm()
sm = 0
factinit(n,R)
for pq in range(n+1):
    if (k-a*pq)%b>0:
        continue
    qr = (k-a*pq)//b
    if qr>n:
        continue
    q1 = max(0,pq+qr-n)
    q2 = min(pq,qr)
    for q in range(q1,q2+1):
        p = pq-q
        r = qr-q
        s = n-p-q-r
        sor = ((fact[p]*fact[q]%R)*(fact[r]*fact[s]%R))%R
        sm = (sm+fact[n]*modinv2(sor,R))%R
print(sm)


# Optimized solution
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 998244353

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

def comb(n,a,R):
    return (fact[n]*modinv2(fact[n-a]*fact[a],R))

def factinit(n,R):
    global fact
    fact = [1]*(n+1)
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%R


n,a,b,k = inm()
sm = 0
factinit(n,R)
for pq in range(n+1):
    if k<a*pq or (k-a*pq)%b>0:
        continue
    qr = (k-a*pq)//b
    if qr>n:
        continue
    sm = (sm+comb(n,pq,R)*comb(n,qr,R))%R
print(sm)
# Original solution
MOD = 998244353
MAX = int(3e5 + 1)


def div(a, b):
    return a * pow(b, MOD-2, MOD) % MOD


FACT = [1] * (MAX+1)
for i in range(1, MAX+1):
    FACT[i] = (i * FACT[i-1]) % MOD
INV = [1] * (MAX+1)
INV[MAX] = div(1, FACT[MAX])
for i in range(MAX, 0, -1):
    INV[i-1] = (INV[i] * i) % MOD


def main():
    N, A, B, K = list(map(int, input().split()))
    ans = 0
    # solve Ax + By = K
    for x in range(N+1):
        By = K - x * A
        if By >= 0 and By % B == 0 and By <= B * N:
            y = By // B
            tmp1 = FACT[N] * INV[x] * INV[N-x] % MOD
            tmp2 = FACT[N] * INV[y] * INV[N-y] % MOD
            ans = (ans + tmp1 * tmp2) % MOD
    print(ans)

if __name__ == "__main__":
    main()


# Optimized solution
MOD = 998244353
MAX = int(3e5 + 10)


def div(a, b):
    return a * pow(b, MOD-2, MOD) % MOD


FACT = [1] * (MAX+1)
for i in range(1, MAX+1):
    FACT[i] = (i * FACT[i-1]) % MOD
INV = [1] * (MAX+1)
INV[MAX] = div(1, FACT[MAX])
for i in range(MAX, 0, -1):
    INV[i-1] = (INV[i] * i) % MOD


def main():
    N, A, B, K = list(map(int, input().split()))
    ans = 0
    # solve Ax + By = K
    for x in range(N+1):
        By = K - x * A
        if By >= 0 and By % B == 0 and By <= B * N:
            y = By // B
            tmp1 = FACT[N] * INV[x] * INV[N-x] % MOD
            tmp2 = FACT[N] * INV[y] * INV[N-y] % MOD
            ans = (ans + tmp1 * tmp2) % MOD
    print(ans)

if __name__ == "__main__":
    main()
# Original solution
def cmb1(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


n, a, b, k = list(map(int, input().split()))
mod = 998244353

ans = 0
for i in range(n+1):
    if k - a*i >= 0 and (k - a*i)%b == 0:
        j = (k - a*i)//b
        ans += cmb1(n, i, mod)*cmb1(n, j, mod)
        ans %= mod

print(ans)

# Optimized solution
n, a, b, k = list(map(int, input().split()))

def cmb1(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(n+1):
    x = a*i
    y = k-x
    if y < 0:
        continue
    if y%b == 0:
        j = y//b
        ans += cmb1(n, i, mod)*cmb1(n, j, mod)
print((ans%mod))
# Original solution
N, A, B, K = tuple(map(int, (input().split())))
mod = 998244353

def ab(n):
    ab = []
    a = n // A
    while (n - A * a) % B != 0:
        a -= 1
    b = (n - A * a) // B
    ab.append((a, b))
    while a > 0:
        a, b = a - B // gcd(A, B), b + A // gcd(A, B)
        if a < 0:
            break
        ab.append((a, b))
    return ab

def gcd(a, b):
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    return gcd(b, a - b * (a // b))

def mpow(x, n):
    ans = 1
    while n != 0:
        if n & 1:
            ans = ans * x % mod
        x = x * x % mod
        n = n >> 1
    return ans

factorial = [1 for i in range(N + 1)]
inverse = [1 for i in range(N + 1)]
for i in range(1, N + 1):
    factorial[i] = (factorial[i - 1] * i) % mod
    inverse[i] = mpow(factorial[i], mod - 2) % mod

com = [((factorial[N] * inverse[r] % mod) * inverse[N - r] % mod) for r in range(0, N + 1)]

ans = 0
for a, b in ab(K):
    if a > N or b > N:
        continue
    ans += com[a] * com[b]
print((ans % mod))

# Optimized solution
N, A, B, K = tuple(map(int, (input().split())))
mod = 998244353

factorial = [1 for i in range(N + 1)]
inverse = [1 for i in range(N + 1)]
for i in range(1, N + 1):
    factorial[i] = (factorial[i - 1] * i) % mod
    inverse[i] = inverse[i - 1] * pow(i, mod - 2, mod) % mod

com = [1 for i in range(N + 1)]
for i in range(1, N + 1):
    com[i] = (factorial[N] * inverse[i] % mod) * inverse[N - i] % mod

ans = 0
for x in range(N + 1):
    d = K - A * x
    if 0 <= d and d % B == 0:
        y = d // B
        if y <= N:
            ans += com[x] * com[y]
print((ans % mod))
# Original solution
# 拡張ユークリッド互除法
# gcd(a,b) と ax + by = gcd(a,b) の最小整数解を返す
def extgcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = extgcd(b % a, a)
        return g, x - (b // a) * y, y

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    gcd, x, y = extgcd(a,m)
    return (m+x%m)%m



N, A, B, K = list(map(int, input().split()))

mod = 998244353
ans = 0
for a in range(N+1):
    if (K - A*a) % B == 0 and A*a <= K:
        b = (K- A*a) // B
        res_a = 1
        for i in range(1,N+1):
            res_a = res_a*i%mod
        for i in range(1,a+1):
            res_a = res_a*mod_inv(i,mod)%mod
        for i in range(1,(N-a)+1):
            res_a = res_a*mod_inv(i,mod)%mod
        res_b = 1
        for i in range(1,N+1):
            res_b = res_b*i%mod
        for i in range(1,b+1):
            res_b = res_b*mod_inv(i,mod)%mod
        for i in range(1,(N-b)+1):
            res_b = res_b*mod_inv(i,mod)%mod
        ans += res_a*res_b%mod

print((ans%mod))



# Optimized solution
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

N, A, B, K = list(map(int, input().split()))

p = 998244353
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0

for a in range(N+1):
    if (K - A*a) % B == 0 and A*a <= K:
        b = (K- A*a) // B
        ans += cmb(N, a, p)*cmb(N, b, p)%p

print((ans%p))
# Original solution
class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0


N, A, B, K = list(map(int, input().split()))
MOD = 998244353

c = Factorial(N + 1, MOD).comb

def calc(a, b):
    return (c(N, a) * c(N, b)) % MOD

ans = 0
for a in range(N + 1):
    b = (K - (A * a)) // B
    if A * a + B * b == K and 0 <= b <= N:
        ans += calc(a, b)
        ans %= MOD

print (ans)


# Optimized solution
def main():
    class Factorial:
        def __init__(self, n, mod):
            self.f = [1]
            self.mod = mod
            for j in range(1, n + 1):
                self.f.append(self.f[-1] * j % mod)
            self.i = [pow(self.f[-1], mod - 2, mod)]
            for j in range(n, 0, -1):
                self.i.append(self.i[-1] * j % mod)
            self.i.reverse()
        def factorial(self, j):
            return self.f[j]
        def ifactorial(self, j):
            return self.i[j]
        def comb(self, n, k):
            return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

    N, A, B, K = list(map(int, input().split()))
    MOD = 998244353

    c = Factorial(N + 1, MOD).comb

    ans = 0
    for a in range(N + 1):
        b = (K - (A * a)) // B
        if A * a + B * b == K and 0 <= b <= N:
            ans += (c(N, a) * c(N, b)) % MOD
            ans %= MOD

    print (ans)

if __name__ == '__main__':
    main()
# Original solution
n, a, b, k = list(map(int, input().split()))

M = 998244353
fact_n = [None for m in range(n+1)]
fact_inv = [None for m in range(n+1)]


def combination(n, r):
    if n == 0 and r == 0:
        return 1
    elif n < r or n < 0:
        return 0

    c = fact_inv[r] * fact_inv[n-r] % M
    return fact_n[n] * c % M


def main():
    fact_n[0] = fact_inv[0] = 1
    for i in range(1, n+1):
        fact_n[i] = fact_n[i-1] * i % M
        fact_inv[i] = fact_inv[i-1] * pow(i, M-2, M) % M

    com = 0
    for i in range(n+1):
        if (k-a*i) % b == 0 and k - a * i >= 0:
            j = (k-a*i) // b
            com += combination(n, i) * combination(n, j) % M

    print((com % M))

    
if __name__ == '__main__':
    main()


# Optimized solution
n, a, b, k = list(map(int, input().split()))

M = 998244353
fact_n = [0 for m in range(n+1)]
fact_inv = [0 for m in range(n+1)]


def combination(n, r):
    if n == 0 and r == 0:
        return 1
    elif n < r or n < 0:
        return 0

    c = fact_inv[r] * fact_inv[n-r] % M
    return fact_n[n] * c % M


def main():
    fact_n[0] = fact_inv[0] = 1
    for i in range(1, n+1):
        fact_n[i] = fact_n[i-1] * i % M
        fact_inv[i] = pow(fact_n[i], M-2, M)

    com = 0
    for i in range(n+1):
        if (k-a*i) % b == 0 and k - a * i >= 0:
            j = (k-a*i) // b
            com += combination(n, i) * combination(n, j) % M

    print((com % M))


if __name__ == '__main__':
    main()
# Original solution
n, a, b, k = list(map(int, input().split()))

M = 998244353
fact_n = [0 for m in range(n+1)]
fact_inv = [0 for m in range(n+1)]


def combination(n, r):
    if n == 0 and r == 0:
        return 1
    elif n < r or n < 0:
        return 0

    c = fact_inv[r] * fact_inv[n-r] % M
    return fact_n[n] * c % M


def main():
    fact_n[0] = fact_inv[0] = 1
    for i in range(1, n+1):
        fact_n[i] = fact_n[i-1] * i % M
        fact_inv[i] = pow(fact_n[i], M-2, M)

    com = 0
    for i in range(n+1):
        if (k-a*i) % b == 0 and k - a * i >= 0:
            j = (k-a*i) // b
            com += combination(n, i) * combination(n, j) % M

    print((com % M))


if __name__ == '__main__':
    main()


# Optimized solution
n, a, b, k = list(map(int, input().split()))

M = 998244353
fact_n = [0 for m in range(n+1)]
fact_inv = [0 for m in range(n+1)]


def mod_pow(a, n):
    x = 1
    while n > 0:
        if n & 1:
            x = x * a % M

        a = a * a % M
        n >>= 1

    return x


def combination(n, r):
    if n == 0 and r == 0:
        return 1
    elif n < r or n < 0:
        return 0

    return fact_n[n] * fact_inv[r] * fact_inv[n-r] % M


def main():
    fact_n[0] = fact_inv[0] = 1
    for i in range(1, n+1):
        fact_n[i] = fact_n[i-1] * i % M

    fact_inv[n] = pow(fact_n[n], M-2, M)
    for i in range(n-1, 0, -1):
        fact_inv[i] = fact_inv[i+1] * (i+1) % M

    com = 0
    for i in range(n+1):
        if (k-a*i) % b == 0 and k - a * i >= 0:
            j = (k-a*i) // b
            com += combination(n, i) * combination(n, j) % M

    print((com % M))


if __name__ == '__main__':
    main()
# Original solution
n,a,b,k = list(map(int,input().split()))
mod = 998244353

fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,n+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod

def nPr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[n-r]%mod


ans = 0
for i in range(n+1):
    d = k-a*i
    if d < 0:
        break
    if d%b:
        continue
    x = d//b
    v = nCr(n,i,mod)
    for j in range(x+1):
        if i+j > n:
            break
        ans += v*nCr(i,x-j,mod)%mod*nCr(n-i,j,mod)%mod
        ans %= mod
print(ans)

# Optimized solution
n,a,b,k = list(map(int,input().split()))
mod = 998244353

fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,n+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod

def nPr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[n-r]%mod


ans = 0
for i in range(n+1):
    if i*a > k:
        break
    d = k-i*a
    if d%b or d//b > n:
        continue
    ans += nCr(n,i,mod)*nCr(n,d//b,mod)%mod
    ans %= mod
print(ans)
# Original solution
mod=998244353
N,A,B,K=list(map(int,input().split()))
 
#繰り返し二乗法
def great_power(x, y):
    if   y == 0:
      return 1
    elif y == 1:
      return x % mod
    elif y % 2 == 0:
      return great_power(x, y//2)**2 % mod
    else:
      return great_power(x, y//2)**2 * x % mod

#階乗計算
factorial=[1]
for i in range(1,N+1):
    factorial.append(factorial[i-1]*i %mod)

#逆元計算
inverse=[0]*(N+1)
inverse[N] = great_power(factorial[N], mod-2)
for i in range(N-1, -1, -1):
    inverse[i] = inverse[i+1] * (i+1) % mod

#combination計算
def nCr(n,r):
  if n==r or n<r:
    return 1
  return factorial[n] * inverse[r] * inverse[n-r] % mod

def solve(a,b,c):
  res=nCr(N,a+b+c)
  res2=factorial[a+b+c] * inverse[a]*inverse[b]*inverse[c]
  return (res*res2)%mod

ans=[]
for i in range(N+1):
  if (K-A*i)%B==0:
    ans.append((i,(K-A*i)//B))

out=0
for x,y in ans:
  for i in range(min(x,y)+1):
    red,green,blue=x-i,i,y-i
    if red+green+blue <=N:
      out+=solve(red,green,blue)
print((out%mod))



# Optimized solution
mod=998244353
N,A,B,K=list(map(int,input().split()))
 
#繰り返し二乗法
def great_power(x, y):
    if   y == 0:
      return 1
    elif y == 1:
      return x % mod
    elif y % 2 == 0:
      return great_power(x, y//2)**2 % mod
    else:
      return great_power(x, y//2)**2 * x % mod

#階乗計算
factorial=[1]
for i in range(1,N+1):
    factorial.append(factorial[i-1]*i %mod)

#逆元計算
inverse=[0]*(N+1)
inverse[N] = great_power(factorial[N], mod-2)
for i in range(N-1, -1, -1):
    inverse[i] = inverse[i+1] * (i+1) % mod

#combination計算
def nCr(n,r):
  if n==r or n<r or r==0:
    return 1
  return factorial[n] * inverse[r] * inverse[n-r] % mod

ans=0

for i in range(N+1):
  if (K-A*i)%B==0 and (K-A*i)>=0:
    j=(K-A*i)//B
    if j <= N:
      ans+=( nCr(N,i) * nCr(N,j) ) %mod
      ans %= mod

print(ans)