func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > hop, top;   int h, t, R;   struct State {     int h, t;     int c;     State() {}     State(int h, int t, int c) : h(h), t(t), c(c) {}     bool operator<(const State o) const {       if (h != o.h) return h < o.h;       return t < o.t;     }   };   vector<vector<int> > G;   pair<int, int> BFS(State init) {     queue<State> q;     q.push(init);     map<State, int> vis;     int ii = 0;     vis[init] = 0;     G.resize(1);     while (q.size()) {       State& s = q.front();       State ns;       for (int i = 0; i < min((int)hop.size(), s.h); i++) {         ns = State(s.h - i - 1 + hop[i].first, s.t + hop[i].second, s.c + 1);         if (ns.h == ns.t && ns.h == 0) {           return make_pair(ns.c, 1);         }         if (ns.h + ns.t > R) {           if (!vis.count(ns)) {             vis[ns] = ++ii;             G.resize(ii + 1);             G[vis[s]].push_back(ii);           }           continue;         }         if (!vis.count(ns)) {           q.push(ns);           vis[ns] = ++ii;           G.resize(ii + 1);           G[vis[s]].push_back(ii);         } else {           G[vis[s]].push_back(vis[ns]);         }       }       for (int i = 0; i < min((int)top.size(), s.t); i++) {         ns = State(s.h + top[i].first, s.t + top[i].second - i - 1, s.c + 1);         if (ns.h == ns.t && ns.h == 0) {           return make_pair(ns.c, 1);         }         if (ns.h + ns.t > R) {           if (!vis.count(ns)) {             vis[ns] = ++ii;             G.resize(ii + 1);             G[vis[s]].push_back(ii);           }           continue;         }         if (!vis.count(ns)) {           q.push(ns);           vis[ns] = ++ii;           G.resize(ii + 1);           G[vis[s]].push_back(ii);         } else {           G[vis[s]].push_back(vis[ns]);         }       }       q.pop();     }     return make_pair(0, -1);   }   enum colors { WHITE, GREY, BLACK };   vector<int> color;   bool hasLoop;   void DFS(int node) {     if (hasLoop) return;     color[node] = GREY;     for (int i = 0; i < G[node].size(); i++) {       if (hasLoop) return;       if (color[G[node][i]] == WHITE) {         DFS(G[node][i]);       } else if (color[G[node][i]] == GREY) {         hasLoop = 1;         return;       }     }     color[node] = BLACK;   }   void Input() {     cin >> h >> t >> R;     int hs, ts;     cin >> hs;     hop.resize(hs);     for (int i = 0; i < hs; i++) {       cin >> hop[i].first >> hop[i].second;     }     cin >> ts;     top.resize(ts);     for (int i = 0; i < ts; i++) {       cin >> top[i].first >> top[i].second;     }   }   vector<int> dp;   int recurse(int node) {     if (dp[node] != -1) return dp[node];     int mx = 0;     for (int i = 0; i < G[node].size(); i++) {       mx = max(mx, recurse(G[node][i]));     }     return dp[node] = mx + 1;   }   void Solve() {     Input();     State init(h, t, 0);     auto ret = BFS(init);     if (ret.second == 1) {       cout <<  Ivan  << endl;       cout << ret.first;       return;     }     color.resize(G.size());     DFS(0);     if (hasLoop) {       cout <<  Draw ;       return;     }     dp.assign(G.size(), -1);     cout <<  Zmey  << endl << recurse(0) - 1;   }   int main() { Solve(); }   