#include #include #include #include #include using namespace std; using namespace atcoder; using ll=long long; using mint=modint998244353; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} template struct Matrix { vector> A; Matrix(int n, int m) : A(n, vector(m, 0)) {} Matrix(int n) : A(n, vector(n, 0)) {} int height() const { return (A.size()); } int width() const { return (A[0].size()); } const vector &operator[](int k) const { return (A[k]); } vector &operator[](int k) { return (A[k]); } static Matrix I(int n) { Matrix mat(n); for (int i = 0; i < n; i++) mat[i][i] = 1; return mat; } Matrix &operator+=(const Matrix &B) { int n = height(), m = width(); assert(n == B.height() && m == B.width()); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { (*this)[i][j] += B[i][j]; } } return (*this); } Matrix &operator-=(const Matrix &B) { int n = height(), m = width(); assert(n == B.height() && m == B.width()); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { (*this)[i][j] -= B[i][j]; } } return (*this); } Matrix &operator*=(const Matrix &B) { int n = height(), m = B.width(), p = width(); assert(p == B.height()); vector> C(n, vector(m, 0)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { for (int k = 0; k < p; k++) { C[i][j] += (*this)[i][k] * B[k][j]; } } } A.swap(C); return (*this); } Matrix &operator^=(long long k) { int n = height(); assert(n == width()); Matrix B = Matrix::I(n); while (k > 0) { if (k & 1) B *= *this; *this *= *this; k >>= 1LL; } A.swap(B.A); return (*this); } Matrix operator+(const Matrix &B) const { return (Matrix(*this) += B); } Matrix operator-(const Matrix &B) const { return (Matrix(*this) -= B); } Matrix operator*(const Matrix &B) const { return (Matrix(*this) *= B); } Matrix operator^(const long long k) const { return (Matrix(*this) ^= k); } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N,M; cin>>N>>M; vectorV; for(int x=1;x*x<=M;x++){ if(M%x==0){ V.push_back(x); if(x*xmat(L); vector ls(L,vector(L)); for(int i=0;i