func_code_string: #include <bits/stdc++.h>   using namespace std;   namespace mainns {   template <typename T>   void relaxMax(T& relaxWhat, const T& relaxBy) {     relaxWhat = max(relaxWhat, relaxBy);   }   template <typename T>   void relaxMin(T& relaxWhat, const T& relaxBy) {     relaxWhat = min(relaxWhat, relaxBy);   }   namespace {   const vector<pair<int, int>> offsets = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};   const unordered_map<char, char> nextLetter = {       { D ,  I }, { I ,  M }, { M ,  A }, { A ,  D }};   }  // namespace   class Solver374C {    public:     void run();     int height, width;     vector<string> board;     vector<vector<int>> maxValues;     int getMaxValue(int x, int y) {       if (maxValues[x][y] > 0) return maxValues[x][y];       if (maxValues[x][y] == -2) return numeric_limits<int>::max() / 10;       maxValues[x][y] = -2;       int maxNeighbourValue = 0;       for (auto& offs : offsets) {         auto neigbour = make_pair(x + offs.first, y + offs.second);         if (neigbour.first >= 0 && neigbour.first < width &&             neigbour.second >= 0 && neigbour.second < height)           if (nextLetter.at(board[y][x]) ==               board[neigbour.second][neigbour.first])             relaxMax(maxNeighbourValue,                      getMaxValue(neigbour.first, neigbour.second));       }       return maxValues[x][y] = maxNeighbourValue + 1;     }   };   void Solver374C::run() {     cin >> height >> width;     board = vector<string>(height);     for (auto& s : board) cin >> s;     maxValues = vector<vector<int>>(width, vector<int>(height, -1));     int maxValue = 0;     for (int x = 0; x < width; ++x)       for (int y = 0; y < height; ++y) {         auto v = getMaxValue(x, y);         if (board[y][x] ==  D ) relaxMax(maxValue, v);       }     if (maxValue < 4)       cout <<  Poor Dima! ;     else if (maxValue >= numeric_limits<int>::max() / 10)       cout <<  Poor Inna! ;     else       cout << (maxValue / 4);   }   }  // namespace mainns   using CurrentSolver = mainns::Solver374C;   int main() {     ios::sync_with_stdio(false);     CurrentSolver().run();     return 0;   }   