#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using mint = modint998244353; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; VVI to(n); rep(_, m) { int u, v; cin >> u >> v; u--, v--; to[u].emplace_back(v); to[v].emplace_back(u); } vector, mint>> dp(n); mint ans; dsu uf(n); rep(v, n) { dp[v].first[v] = 1; int vl = v; for (int u : to[v]) if (u < v) { int ul = uf.leader(u); if (ul == vl) continue; if (dp[ul].first.size() > dp[vl].first.size()) { swap(dp[ul], dp[vl]); } for (auto [i, c] : dp[ul].first) { auto it = dp[vl].first.find(i); if (it == dp[vl].first.end()) dp[vl].first[i] = c + dp[ul].second - dp[vl].second; else { it->second += c + dp[ul].second; } } // if (v == 2) exit(0); dp[ul].first.clear(); int l = uf.merge(ul, vl); if (vl != l) { dp[l] = move(dp[vl]); vl = l; } } mint val = dp[vl].first[v] + dp[vl].second; ans += val; // cout << v << ' ' << val.val() << endl; for (int u : to[v]) if (u > v) { auto it = dp[vl].first.find(u); if (it == dp[vl].first.end()) dp[vl].first[u] = -dp[vl].second; } dp[vl].second += val; // if (v == 1) cout << (dp[vl].first[2] + dp[vl].second).val() << endl, exit(0); } cout << ans.val() << '\n'; }