#include #include using namespace std; // Naive DP (TLE) // Complexity: O(HWT), H = (2^^X) - 1, W = (2^^Y) - 1 int main() { int X, Y; long long T; int a, b, c, d; cin >> X >> Y >> T >> a >> b >> c >> d; vector dp((1 << X) + 1, vector((1 << Y) + 1)); dp[a][b] = 1; while (T--) { vector nxt = dp; for (int i = 1; i < 1 << X; i++) { for (int j = 1; j < 1 << Y; j++) { nxt[i][j] = (dp[i][j] + dp[i + 1][j] + dp[i - 1][j] + dp[i][j + 1] + dp[i][j - 1]) % 998244353; } } dp = nxt; } cout << dp[c][d] << '\n'; }