simple maths
\n\n# Code\ncpp []\nclass Solution {\npublic:\n    const int mod = 1e9+7;\n    vector<long long> fact;\n    void sieve()\n    {\n        fact.resize(31,0);\n   
\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    const int mod = 1e9+7;\n    vector<long long> fact;\n    void sieve()\n    {\n        fact.resize(31,0);\n        fact[0] = 1;\n        for(int i = 1; i<=30; i++)\n        {\n            fact[i] = fact[i-1];\n            fact[i] *= i;\n            fact[i] %= mod;\n        }\n    }\n    long long binexp(int a, int b, int mod)\n    {\n        long long prod = 1;\n        while(b)\n        {\n            if(b&1)\n            {\n                prod = (prod*1LL*a)%mod;\n            }\n            a = (a*1LL*a)%mod;\n            b >>= 1;\n        }\n        return prod;\n    }\n    long long nCr(int n, int r)\n    {\n        long long val1 = fact[n];\n        long long val2 = fact[r];\n        long long val3 = fact[n-r];\n\n        val2 *= val3;\n        val2 %= mod;\n\n        val2 = binexp(val2,mod-2,mod);\n        val1 *= val2;\n        val1 %= mod;\n        return val1;\n    }\n    string fun(int ct1, int ct2, int k)\n    {\n        string str;\n        int n = ct1+ct2;\n        for(int i = 0; i<n; i++)\n        {\n            if(ct1 > 0)\n            {\n                int val1 = nCr(ct1+ct2-1,ct1-1);\n                if(val1 >= k)\n                {\n                    str.push_back(\'H\');\n                    ct1--;\n                }\n                else\n                {\n                    k -= val1;\n                    str.push_back(\'V\');\n                    ct2--;\n                }\n            }\n            else\n            {\n                str.push_back(\'V\');\n                ct2--;\n            }\n        }\n        return str;\n    }\n    string kthSmallestPath(vector<int>& destination, int k) {\n        sieve();\n        return fun(destination[1],destination[0],k);\n    }\n};\n```
['C++']