#ifndef DEBUG #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("tune=native") #endif #include #include using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; // using mint = modint1000000007; template using vec = vector; template using pr = pair; template using mipq = priority_queue, greater>; #define overload4(_1, _2, _3, _4, name, ...) name #define rep1(i, n) for (auto i = decay_t{}; i < (n); i++) #define rep2(i, l, r) for (auto i = (l); i < (r); i++) #define rep3(i, l, r, d) for (auto i = (l); i < (r); i += (d)) #define rep(...) overload4(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__) #define rrep(i, r, l) for (auto i = (r); i >= (l); i--) template bool chmax(T& a, const T& b) { return a < b ? a = b, true : false; } template bool chmin(T& a, const T& b) { return a > b ? a = b, true : false; } constexpr int INF = 1 << 30; constexpr ll LINF = 1LL << 60; void solve(); int main() { cin.tie(nullptr)->sync_with_stdio(false); cout << fixed << setprecision(15); int T = 1; // cin >> T; while (T--) solve(); } // 行列累乗しろってことー? using mat = vec>; mat mul(const mat& a, const mat& b) { int n = a.size(); mat res(n, vec(n)); rep(i, n) rep(k, n) rep(j, n) res[i][j] += a[i][k] * b[k][j]; return res; } mat pow(mat x, ll k) { int n = x.size(); mat res(n, vec(n)); rep(i, n) res[i][i] = 1; while (k) { if (k & 1) res = mul(res, x); x = mul(x, x); k >>= 1; } return res; } void solve() { int N, M; cin >> N >> M; vec> G(N); rep(i, M) { int u, v; cin >> u >> v; u--; v--; G[u].emplace_back(v); G[v].emplace_back(u); } mat trans(N, vec(N)); rep(u, N) { mint p = mint(G[u].size()).inv(); for (auto v : G[u]) trans[u][v] = p; } ll S, T; int A, B; cin >> S >> T >> A >> B; S--; T--; A--; B--; mint res = pow(trans, T)[0][B] * pow(trans, S - T)[B][A] / pow(trans, S)[0][A]; cout << res.val() << '\n'; }