import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**16 md = 998244353 # md = 10**9+7 def dot(aa, bb): return [[sum(a*b%md for a, b in zip(row, col))%md for col in zip(*bb)] for row in aa] ma, na, s = LI() mb, nb, t = LI() K = II() s += t s, t = t, s pa = ma*pow(na, md-2, md) pb = mb*pow(nb, md-2, md) # print(pa,pb) dtop = [0]*(t+1) now = (1-pa)%md for i in range(t+1): dtop[i] = now now = now*pa%md pp0 = [[0]*(t+1) for _ in range(t+1)] for i in range(1, t): p = 1 d = 0 for j in range(i, t): pp0[i][j] = dtop[d] p -= dtop[d] d += 1 pp0[i][t] = p%md # p2D(pp0) dtop = [0]*(t+1) now = (1-pb)%md for i in range(t+1): dtop[i] = now now = now*pb%md pp1 = [[0]*(t+1) for _ in range(t+1)] for i in range(t-1, 0, -1): p = 1 d = 0 for j in range(i, 0, -1): pp1[i][j] = dtop[d] p -= dtop[d] d += 1 pp1[i][0] = p%md base = [[0]*(t+1) for _ in range(t+1)] for i in range(1, t): for j in range(i, t): for k in range(j+1): base[k][i] += pp0[i][j]*pp1[j][k] base[k][i] %= md for i in range(1, t): base[t][i] = pp0[i][t] base[0][0] = 1 base[t][t] = 1 # p2D(base) cc = [[0]*(t+1) for _ in range(t+1)] for i in range(t+1): cc[i][i] = 1 for i in range(K.bit_length()): if K >> i & 1: cc = dot(cc, base) base = dot(base, base) # print(s,t) # p2D(cc) print(cc[t][s]) print(cc[0][s])