#include <bits/stdc++.h>
const int MAXN = 4e5 + 5;
int n, m, k;
int pw[31];
struct Node {
  int x1, y1, x2, y2;
  Node(int x1 = 0, int y1 = 0, int x2 = 0, int y2 = 0)
      : x1(x1), y1(y1), x2(x2), y2(y2) {}
} a[MAXN], b[MAXN];
struct Event {
  int x, y1, y2, d;
  Event(int x = 0, int y1 = 0, int y2 = 0, int d = 0)
      : x(x), y1(y1), y2(y2), d(d) {}
  inline bool operator<(const Event &t) const { return x < t.x; }
};
long long sm[MAXN << 2];
int tag[MAXN << 2];
std::vector<int> S;
inline void build(int x, int l, int r) {
  tag[x] = sm[x] = 0;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(((x) << 1), l, mid);
  build(((x) << 1 | 1), mid + 1, r);
}
inline void modify(int x, int l, int r, int L, int R, int d) {
  if (L > R) return;
  int len = S[r - 1] - (l == 1 ? 0 : S[l - 2]);
  if (l == L && r == R) {
    tag[x] += d;
    if (tag[x])
      sm[x] = len;
    else
      sm[x] = sm[((x) << 1)] + sm[((x) << 1 | 1)];
    return;
  }
  int mid = (l + r) >> 1;
  if (R <= mid)
    modify(((x) << 1), l, mid, L, R, d);
  else if (L > mid)
    modify(((x) << 1 | 1), mid + 1, r, L, R, d);
  else
    modify(((x) << 1), l, mid, L, mid, d),
        modify(((x) << 1 | 1), mid + 1, r, mid + 1, R, d);
  if (tag[x])
    sm[x] = len;
  else
    sm[x] = sm[((x) << 1)] + sm[((x) << 1 | 1)];
}
inline int work(int c) {
  int U = (1 << c) - 1;
  S.clear();
  std::vector<Event> G;
  for (int i = 1; i <= m; ++i) {
    a[i].x1 = (b[i].x1 >> c);
    a[i].y1 = (b[i].y1 >> c);
    a[i].x2 = (b[i].x2 >> c);
    a[i].y2 = (b[i].y2 >> c);
    if (a[i].x1 > a[i].x2 || a[i].y1 > a[i].y2) continue;
    if (b[i].x1 & U) a[i].x1++;
    if (b[i].y1 & U) a[i].y1++;
    S.push_back(a[i].y1 - 1);
    S.push_back(a[i].y2);
    G.push_back(Event(a[i].x1, a[i].y1 - 1, a[i].y2, 1));
    G.push_back(Event(a[i].x2 + 1, a[i].y1 - 1, a[i].y2, -1));
  }
  std::sort(S.begin(), S.end());
  S.erase(std::unique(S.begin(), S.end()), S.end());
  for (auto &x : G) {
    x.y1 = std::lower_bound(S.begin(), S.end(), x.y1) - S.begin() + 1;
    x.y2 = std::lower_bound(S.begin(), S.end(), x.y2) - S.begin() + 1;
  }
  int m = S.size();
  std::sort(G.begin(), G.end());
  build(1, 1, m);
  int las = 0, ans = 0, ps = 0;
  while (ps < G.size()) {
    int t = G[ps].x;
    ans += (G[ps].x - las) * sm[1];
    while (ps + 1 < G.size() && G[ps + 1].x == t)
      modify(1, 1, m, G[ps].y1 + 1, G[ps].y2, G[ps].d), ++ps;
    modify(1, 1, m, G[ps].y1 + 1, G[ps].y2, G[ps].d);
    las = G[ps].x;
    ++ps;
  }
  return ans;
}
int ans[MAXN];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; ++i)
    scanf("%d%d%d%d", &b[i].x1, &b[i].y1, &b[i].x2, &b[i].y2);
  for (int i = 0; i <= 30; ++i) ans[i] = work(i);
  int p = 0;
  while ((1 << (p + 1)) <= k) ++p;
  for (int i = 0; i <= p - 1; ++i) {
    if ((ans[i] - ans[i + 1]) & 1) {
      puts("Hamed");
      return 0;
    }
  }
  puts(ans[p] & 1 ? "Hamed" : "Malek");
  return 0;
}
