Problem: Once upon a time in a kingdom far, far away… Okay, let’s start at the point where Ivan the Fool met Gorynych the Dragon. Ivan took out his magic sword and the battle began. First Gorynych had h heads and t tails. With each strike of the sword Ivan can either cut off several heads (from 1 to n, but not more than Gorynych has at the moment), or several tails (from 1 to m, but not more than Gorynych has at the moment). At the same time, horrible though it seems, Gorynych the Dragon can also grow new heads and tails. And the number of growing heads and tails is determined uniquely by the number of heads or tails cut by the current strike. When the total number of heads and tails exceeds R, Gorynych the Dragon strikes its final blow and destroys Ivan the Fool. That’s why Ivan aims to cut off all the dragon’s heads and tails as quickly as possible and win. The events can also develop in a third way: neither of the opponents can win over the other one and they will continue fighting forever.

The tale goes like this; easy to say, hard to do. Your task is to write a program that will determine the battle’s outcome. Consider that Ivan strikes consecutively. After each blow Gorynych grows a number of new heads and tails depending on the number of cut ones. Gorynych the Dragon is defeated if after the blow he loses all his heads and tails and can’t grow new ones. Ivan fights in the optimal way (fools are lucky), i.e. 

  * if Ivan can win, he wins having struck the least number of blows; 
  * if it is impossible to defeat Gorynych, but is possible to resist him for an infinitely long period of time, then that’s the strategy Ivan chooses; 
  * if Gorynych wins in any case, Ivan aims to resist him for as long as possible. 

Input

The first line contains three integers h, t and R (0 ≤ h, t, R ≤ 200, 0 < h + t ≤ R) which represent the initial numbers of Gorynych’s heads and tails and the largest total number of heads and tails with which Gorynych the Dragon does not yet attack. The next line contains integer n (1 ≤ n ≤ 200). The next n contain pairs of non-negative numbers "hi ti" which represent the number of heads and the number of tails correspondingly, that will grow if Gorynych has i heads (1 ≤ i ≤ n) cut. The next line contains an integer m (1 ≤ m ≤ 200) and then — the description of Gorynych’s behavior when his tails are cut off in the format identical to the one described above. All the numbers in the input file do not exceed 200. 

Output

Print "Ivan" (without quotes) in the first line if Ivan wins, or "Zmey" (that means a dragon in Russian) if Gorynych the Dragon wins. In the second line print a single integer which represents the number of blows Ivan makes. If the battle will continue forever, print in the first line "Draw".

Examples

Input

2 2 4
2
1 0
0 1
3
0 1
0 1
0 0


Output

Ivan
2


Input

2 2 4
1
0 1
1
1 0


Output

Draw


Input

2 2 5
1
1 1
1
3 0


Output

Zmey
2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 203 * 203 + 200, INF = 1 << 25;
int __count__;
template <class t>
ostream &operator<<(ostream &tout, const vector<t> &s) {
  tout << '[';
  for (int i = 0; i < s.size(); i++)
    if (i + 1 == s.size())
      tout << s[i];
    else
      tout << s[i] << ',';
  tout << ']';
  return (tout);
}
vector<int> e[MAX_N], re[MAX_N], sorted, Glo;
vector<vector<int> > ans;
bool mark[MAX_N];
struct StronglyConnected {
  int n;
  StronglyConnected(int s) {
    n = s;
    for (int i = 0; i < MAX_N; i++) {
      e[i].clear();
      mark[i] = false;
      re[i].clear();
    }
    sorted.clear();
    ans.clear();
  }
  inline void dfs(int s) {
    if (mark[s]) return;
    mark[s] = true;
    Glo.push_back(s);
    for (int i = 0; i < e[s].size(); i++) dfs(e[s][i]);
    sorted.push_back(s);
  }
  inline void push_back(int a, int b) { e[a].push_back(b); }
  vector<vector<int> > Components() {
    for (int i = 1; i <= n; i++)
      if (!mark[i]) dfs(i);
    reverse(sorted.begin(), sorted.end());
    for (int i = 1; i <= n; i++)
      for (int j = 0; j < e[i].size(); j++) re[e[i][j]].push_back(i);
    for (int i = 1; i <= n; i++) swap(e[i], re[i]);
    vector<vector<int> > ans;
    fill(mark + 1, mark + n + 1, false);
    for (int i = 1; i <= n; i++)
      if (!mark[sorted[i - 1]]) {
        Glo.clear();
        dfs(sorted[i - 1]);
        ans.push_back(Glo);
      }
    return (ans);
  }
};
vector<vector<int> > __fuck__;
vector<int> qu;
vector<int> dist;
template <typename type>
vector<pair<type, int> > bfs(vector<pair<type, type> > yal, type s) {
  __fuck__ = vector<vector<int> >(__count__ + 1);
  for (int i = 0; i < yal.size(); i++)
    __fuck__[yal[i].first].push_back(yal[i].second);
  dist = vector<int>(__count__ + 1, INF);
  qu.push_back(s);
  dist[s] = 0;
  vector<pair<type, int> > ans;
  for (int first = 0; first < qu.size(); first++) {
    ans.push_back(pair<type, int>(qu[first], dist[qu[first]]));
    type x = qu[first];
    for (int i = 0; i < __fuck__[x].size(); i++)
      if (dist[__fuck__[x][i]] == INF) {
        dist[__fuck__[x][i]] = dist[x] + 1;
        qu.push_back(__fuck__[x][i]);
      }
  }
  return (ans);
}
vector<pair<int, int> > res;
int main() {
  int h, r, t, n, m;
  cin >> h >> t >> r;
  cin >> n;
  vector<pair<int, int> > head, tail;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    head.push_back(pair<int, int>(x, y));
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    tail.push_back(pair<int, int>(x, y));
  }
  vector<vector<int> > number(r + 1, vector<int>(r + 1));
  __count__ = 1;
  for (int i = 0; i < number.size(); i++)
    for (int j = 0; j < number[i].size(); j++, __count__++)
      number[i][j] = __count__;
  vector<pair<int, int> > edges;
  for (int i = 0; i < number.size(); i++)
    for (int j = 0; j < number[i].size(); j++)
      if (i + j <= r && i + j > 0) {
        for (int a = 0; a < head.size() && a < i; a++) {
          int x = i - a - 1 + head[a].first;
          int y = j + head[a].second;
          if (x + y <= r)
            edges.push_back(pair<int, int>(number[i][j], number[x][y]));
          else
            edges.push_back(pair<int, int>(number[i][j], __count__));
        }
        for (int a = 0; a < tail.size() && a < j; a++) {
          int x = i + tail[a].first;
          int y = j - a - 1 + tail[a].second;
          if (x + y <= r)
            edges.push_back(pair<int, int>(number[i][j], number[x][y]));
          else
            edges.push_back(pair<int, int>(number[i][j], __count__));
        }
      }
  int start = number[h][t];
  res = bfs(edges, start);
  for (int i = 0; i < res.size(); i++)
    if (res[i].first == 1) {
      cout << "Ivan" << endl;
      cout << res[i].second << endl;
      return (0);
    }
  StronglyConnected mai(__count__);
  for (int i = 0; i < edges.size(); i++)
    mai.push_back(edges[i].first, edges[i].second);
  vector<vector<int> > faces = mai.Components();
  vector<int> places(__count__ + 1);
  for (int i = 0; i < faces.size(); i++)
    for (int j = 0; j < faces[i].size(); j++) places[faces[i][j]] = i;
  vector<vector<int> > e(faces.size());
  for (int i = 0; i < edges.size(); i++)
    e[places[edges[i].first]].push_back(places[edges[i].second]);
  vector<int> Max(faces.size(), -INF);
  for (int i = 0; i < faces.size(); i++)
    for (int j = 0; j < faces[i].size(); j++)
      if (faces[i][j] == start) Max[i] = 0;
  for (int i = 0; i < e.size(); i++)
    for (int j = 0; j < e[i].size(); j++)
      Max[e[i][j]] = max(Max[e[i][j]], Max[i] + 1);
  for (int i = 0; i < faces.size(); i++)
    if (Max[i] >= 0 && faces[i].size() > 1) {
      cout << "Draw" << endl;
      return (0);
    }
  for (int i = 0; i < Max.size(); i++)
    if (Max[i] >= 0) {
      bool find = false;
      for (int j = 0; j < e[i].size(); j++)
        if (e[i][j] == i) find = true;
      if (find) {
        cout << "Draw" << endl;
        return (0);
      }
    }
  for (int i = 0; i < faces.size(); i++)
    for (int j = 0; j < faces[i].size(); j++)
      if (faces[i][j] == __count__) {
        cout << "Zmey" << endl;
        cout << Max[i] << endl;
        return (0);
      }
}