#include #include #include #include #include #include using namespace std; #define int long long #define rep(i,n) for(int i = 0; i < (n); i++) #define endl "\n" const long long INF = (long long)1e18; // const long long MOD = (long long)1e9 + 7; long long MOD; string yn(bool f){return f?"Yes":"No";} string YN(bool f){return f?"YES":"NO";} #define MAX vector> product(vector> &a, vector> &b){ vector> res(a.size(),vector(b[0].size(),0)); for(int i = 0; i < a.size(); i++){ for(int j = 0; j < b[0].size(); j++){ for(int k = 0; k < b.size(); k++){ res[i][j] += a[i][k]*b[k][j]; res[i][j] %= MOD; } } } return res; } int solve(int n){ if(n <= 1) return n; vector> ans(2,vector(1)), matrix(2,vector(2)); ans[0][0] = 1; ans[1][0] = 0; matrix[0][0] = matrix[0][1] = matrix[1][0] = 1; matrix[1][1] = 0; n--; while(n){ if(n&1) ans = product(ans,matrix); matrix = product(matrix,matrix); n >>= 1; } return ans[0][0]; } signed main(){ cin.tie(0); ios::sync_with_stdio(false); cout<>n>>MOD; cout<