// -fsanitize=undefined, // #define _GLIBCXX_DEBUG #pragma GCC target("avx2") #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace atcoder; #define rep(i,n) for (int i=0;i-1;i--) #define pb push_back #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << " )\n"; template using vec = vector; template using vvec = vec>; template using vvvec = vec>; using ll = long long; using pii = pair; using pll = pair; template bool chmin(T &a, T b){ if (a>b){ a = b; return true; } return false; } template bool chmax(T &a, T b){ if (a T sum(vec x){ T res=0; for (auto e:x){ res += e; } return res; } template void printv(vec x){ for (auto e:x){ cout< ostream& operator<<(ostream& os, const pair& A){ os << "(" << A.first <<", " << A.second << ")"; return os; } template ostream& operator<<(ostream& os, const set& S){ os << "set{"; for (auto a:S){ os << a; auto it = S.find(a); it++; if (it!=S.end()){ os << ", "; } } os << "}"; return os; } using mint = modint998244353; ostream& operator<<(ostream& os, const mint& a){ os << a.val(); return os; } template ostream& operator<<(ostream& os, const vec& A){ os << "["; rep(i,A.size()){ os << A[i]; if (i!=A.size()-1){ os << ", "; } } os << "]" ; return os; } template vector& operator+=(vector& a, const vector& b) { if (a.size() < b.size()) { a.resize(b.size()); } for (int i = 0; i < (int)b.size(); i++) { a[i] += b[i]; } return a; } template vector operator+(const vector& a, const vector& b) { vector c = a; return c += b; } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int N,M; cin>>N>>M; vec> edge(N); vec> to_big(N); rep(i,M){ int u,v; cin>>u>>v; u--; v--; edge[max(u,v)].push_back(min(u,v)); to_big[min(u,v)].insert(max(u,v)); } vector dp(N,1); vector lazy_add(N,0); vector root(N,-1); vector> G(N); vector> add_to_big(N); rep(i,N){ root[i] = i; G[i].push_back(i); } auto merge = [&](int u,int v){ u = root[u]; v = root[v]; if (u == v) return ; if (G[u].size() > G[v].size()) swap(u,v); for (auto x:G[u]){ root[x] = v; G[v].push_back(x); } G[u].clear(); for (auto [big,val]:add_to_big[u]){ if (!add_to_big[v].count(big)){ add_to_big[v][big] = -lazy_add[v]; } add_to_big[v][big] += lazy_add[u] + val; } }; for (int i=0;i done; for (auto nv:edge[i]){ int r = root[nv]; if (done.count(r)) continue; if (add_to_big[r].count(i)){ dp[i] += add_to_big[r][i] + lazy_add[r]; add_to_big[r].erase(i); } } for (auto nv:to_big[i]){ add_to_big[i][nv] = 0; } for (auto nv:edge[i]){ merge(nv,i); } lazy_add[root[i]] += dp[i]; } mint ans = accumulate(all(dp),mint(0)); //debug(dp); cout << ans << endl; }