DP
Dp states: turn(who is playing) ,index of last chosen location of pawn(which is equal to current knights location), (bitmask of size 16 for storing visted info 
Dp states: turn(who is playing) ,index of last chosen location of pawn(which is equal to current knights location), (bitmask of size 16 for storing visted info of pawn)\nUse BFS to get shortest moves\nT.C: O(2*n* (1<<n)) n is number of pawns on board\nS.C: O(2*n* (1<<n)) + O(size of baord ^2)(BFS precompute)\n# Code\n```cpp []\nclass Solution {\npublic:\n    int dp[2][17][66000];\n    int mv[51][51][51][51];\n    \n    int play(int t, int kx, int ky, int ls, vector<vector<int>>& positions, int n){\n        if(n== (1<<(positions.size()))-1) return 0;\n        if(dp[t][ls][n]!=-1) return dp[t][ls][n];\n        int mv1;\n        mv1= t? INT_MAX: INT_MIN;\n        for(int i=0; i<positions.size(); i++){\n            if((n & (1<<i))==0){\n                if(t){\n                    mv1= min(getMoves(kx, ky, positions[i][0], positions[i][1], positions)+ play(1-t, positions[i][0], positions[i][1], i+1, positions, n | (1<<i)), mv1);\n                }else{\n                    mv1= max(getMoves(kx, ky, positions[i][0], positions[i][1], positions)+ play(1-t, positions[i][0], positions[i][1], i+1, positions, n | (1<<i)), mv1);\n                }\n                    \n            }\n        }\n        return dp[t][ls][n]=mv1;\n    }\n    int getMoves(int kx, int ky, int x, int y, vector<vector<int>>& positions){\n        if(mv[kx][ky][x][y]!=-1) return mv[kx][ky][x][y];\n        for(auto p: positions){\n            mv[kx][ky][p[0]][p[1]]= bfs(kx, ky, p[0], p[1]);\n        }\n        for(auto p: positions){\n            for(auto p1: positions){\n                mv[p1[0]][p1[1]][p[0]][p[1]]=  bfs(p1[0], p1[1], p[0], p[1]);\n                mv[p[0]][p[1]][p1[0]][p1[1]]=  mv[p1[0]][p1[1]][p[0]][p[1]];\n            }\n        }\n            \n        \n        return mv[kx][ky][x][y];\n        \n    }\n    bool check(int x, int y){\n        return x>=0 && y>=0 && x<50 && y<50;\n    }\n    \n    int bfs(int kx, int ky, int x, int y){\n        \n        queue<pair<int, int>> q;\n        int dx[8]={2, 1, -1, -2, 2, 1, -1, -2};\n        int dy[8]={1, 2,  2,  1, -1, -2, -2, -1};\n        q.push({kx, ky});\n        int l=0;\n        vector<vector<int>> vis(50, vector<int>(50, 0));\n        vis[kx][ky]=1;\n        while(!q.empty()){\n            int sz= q.size();\n            for(int z=0; z<sz; z++){\n                \n                auto node= q.front();\n                q.pop();\n                if(node.first==x && node.second==y){\n                    return l;\n                }\n\n                for(auto k: {0, 1, 2,3, 4, 5, 6, 7}){\n                    int nx= node.first+ dx[k];\n                    int ny= node.second+ dy[k];\n                    if (check(nx, ny) && vis[nx][ny]==0){\n                        q.push({nx, ny});\n                        vis[nx][ny]=1;\n                    }\n\n                }\n            }\n            l++;\n        }\n       \n        return 0;\n    }\n    \n    int maxMoves(int kx, int ky, vector<vector<int>>& positions) {\n        memset(dp, -1, sizeof dp);\n        memset(mv, INT_MAX, sizeof mv);\n        return play(0, kx, ky, 0, positions, 0);\n        \n    }\n};\n```
['C++']