#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using Int = long long; template ostream &operator<<(ostream &os, const pair &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template ostream &operator<<(ostream &os, const vector &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; } template void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; } template bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; } #define COLOR(s) ("\x1b[" s "m") //////////////////////////////////////////////////////////////////////////////// template struct ModInt { static constexpr unsigned M = M_; unsigned x; constexpr ModInt() : x(0U) {} constexpr ModInt(unsigned x_) : x(x_ % M) {} constexpr ModInt(unsigned long long x_) : x(x_ % M) {} constexpr ModInt(int x_) : x(((x_ %= static_cast(M)) < 0) ? (x_ + static_cast(M)) : x_) {} constexpr ModInt(long long x_) : x(((x_ %= static_cast(M)) < 0) ? (x_ + static_cast(M)) : x_) {} ModInt &operator+=(const ModInt &a) { x = ((x += a.x) >= M) ? (x - M) : x; return *this; } ModInt &operator-=(const ModInt &a) { x = ((x -= a.x) >= M) ? (x + M) : x; return *this; } ModInt &operator*=(const ModInt &a) { x = (static_cast(x) * a.x) % M; return *this; } ModInt &operator/=(const ModInt &a) { return (*this *= a.inv()); } ModInt pow(long long e) const { if (e < 0) return inv().pow(-e); ModInt a = *this, b = 1U; for (; e; e >>= 1) { if (e & 1) b *= a; a *= a; } return b; } ModInt inv() const { unsigned a = M, b = x; int y = 0, z = 1; for (; b; ) { const unsigned q = a / b; const unsigned c = a - q * b; a = b; b = c; const int w = y - static_cast(q) * z; y = z; z = w; } assert(a == 1U); return ModInt(y); } ModInt operator+() const { return *this; } ModInt operator-() const { ModInt a; a.x = x ? (M - x) : 0U; return a; } ModInt operator+(const ModInt &a) const { return (ModInt(*this) += a); } ModInt operator-(const ModInt &a) const { return (ModInt(*this) -= a); } ModInt operator*(const ModInt &a) const { return (ModInt(*this) *= a); } ModInt operator/(const ModInt &a) const { return (ModInt(*this) /= a); } template friend ModInt operator+(T a, const ModInt &b) { return (ModInt(a) += b); } template friend ModInt operator-(T a, const ModInt &b) { return (ModInt(a) -= b); } template friend ModInt operator*(T a, const ModInt &b) { return (ModInt(a) *= b); } template friend ModInt operator/(T a, const ModInt &b) { return (ModInt(a) /= b); } explicit operator bool() const { return x; } bool operator==(const ModInt &a) const { return (x == a.x); } bool operator!=(const ModInt &a) const { return (x != a.x); } friend std::ostream &operator<<(std::ostream &os, const ModInt &a) { return os << a.x; } }; //////////////////////////////////////////////////////////////////////////////// constexpr unsigned MO = 998244353; using Mint = ModInt; // https://x.com/NachiaVivias/status/1863300035263553791/photo/1 int N, M; vector A, B; vector> graph; vector>> graphI; int main() { for (; ~scanf("%d%d", &N, &M); ) { A.resize(M); B.resize(M); for (int i = 0; i < M; ++i) { scanf("%d%d", &A[i], &B[i]); --A[i]; --B[i]; } graph.assign(N, {}); graphI.assign(N, {}); for (int i = 0; i < M; ++i) { graph[A[i]].push_back(B[i]); graph[B[i]].push_back(A[i]); graphI[A[i]].emplace_back(B[i], i); graphI[B[i]].emplace_back(A[i], i); } vector deg(N); for (int u = 0; u < N; ++u) deg[u] = graph[u].size(); vector us(N); for (int u = 0; u < N; ++u) us[u] = u; sort(us.begin(), us.end(), [&](int u, int v) -> bool { return (deg[u] > deg[v]); }); vector ord(N, -1); for (int j = 0; j < N; ++j) ord[us[j]] = j; // cerr<<"us = "< tri(M, 0); // \sum[u] min{deg(u)^2, M} <= \sum[u] deg[u] sqrt(M) = O(M sqrt(M)) { vector fs(N, 0); for (int j = 0; j < N; ++j) { const int u = us[j]; for (const auto &vi : graphI[u]) if (ord[u] < ord[vi.first]) { fs[vi.first] = ~vi.second; } for (const auto &vi : graphI[u]) if (ord[u] < ord[vi.first]) { const int v = vi.first; for (const auto &wi : graphI[v]) if (ord[v] < ord[wi.first]) { const int w = wi.first; if (fs[w]) { // C[3] // cerr<<"C3 "<,int>brt; for(int p=0;p<1<ds; for(int u=0;u>u&1){ int d=0; for(const int v:graph[u])if(p>>v&1)++d; ds.push_back(d); } sort(ds.begin(),ds.end(),greater{}); ++brt[ds]; } for(const auto&kv:brt)cerr<