#include <bits/stdc++.h>
using namespace std;
int n, m, k, tx, ty;
int X[1000005 << 1], Y[1000005 << 1];
int calc(int x) { return x ^ (x >> 1); }
int calc(int l, int r) {
  int t = ((r / k) & 1) ^ (((l - 1) / k) & 1);
  int tmp = calc(r % k) ^ calc((l - 1) % k);
  if (t) tmp ^= calc(k);
  return tmp;
}
struct SMT {
  int val[1000005 << 3], cnt[1000005 << 3];
  void push_up(int pos, int l, int r) {
    if (cnt[pos] && r != ty)
      val[pos] = calc(Y[l], Y[r + 1] - 1);
    else
      val[pos] = val[pos << 1] ^ val[pos << 1 | 1];
    return;
  }
  void update(int pos, int l, int r, int nl, int nr, int w) {
    if (l >= nl && r <= nr) return cnt[pos] += w, push_up(pos, l, r), void();
    int mid = (l + r) >> 1;
    if (mid >= nl) update(pos << 1, l, mid, nl, nr, w);
    if (mid < nr) update(pos << 1 | 1, mid + 1, r, nl, nr, w);
    push_up(pos, l, r);
    return;
  }
} T;
struct Line {
  int xl, xr, yl, yr;
} p[1000005];
vector<pair<int, int> > l[1000005 << 1];
int read();
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 30; ~i; --i)
    if (k & (1 << i)) {
      k = 1 << i;
      break;
    }
  for (int i = 1; i <= m; ++i) {
    int xl = read(), yl = read(), xr = read() + 1, yr = read() + 1;
    p[i] = (Line){xl, xr, yl, yr};
    X[++tx] = xl, X[++tx] = xr;
    Y[++ty] = yl, Y[++ty] = yr;
  }
  X[++tx] = 1;
  X[++tx] = 1e9 + 1;
  Y[++ty] = 1;
  Y[++ty] = 1e9 + 1;
  sort(X + 1, X + 1 + tx);
  sort(Y + 1, Y + 1 + ty);
  tx = unique(X + 1, X + 1 + tx) - X - 1;
  ty = unique(Y + 1, Y + 1 + ty) - Y - 1;
  for (int i = 1; i <= m; ++i) {
    int xl, xr, yl, yr;
    xl = lower_bound(X + 1, X + 1 + tx, p[i].xl) - X;
    xr = lower_bound(X + 1, X + 1 + tx, p[i].xr) - X;
    yl = lower_bound(Y + 1, Y + 1 + ty, p[i].yl) - Y;
    yr = lower_bound(Y + 1, Y + 1 + ty, p[i].yr) - Y;
    l[xl].push_back(make_pair(yl, yr));
    l[xr].push_back(make_pair(-yl, -yr));
  }
  int res = 0;
  for (int i = 1; i < tx; ++i) {
    int sz = l[i].size();
    for (int j = 0; j < sz; ++j)
      if (l[i][j].first < 0)
        T.update(1, 1, ty, -l[i][j].first, -l[i][j].second - 1, -1);
      else
        T.update(1, 1, ty, l[i][j].first, l[i][j].second - 1, 1);
    int tmp1 = T.val[1], tmp2 = calc(X[i], X[i + 1] - 1), t = 0;
    for (int i = 30; ~i; --i) {
      if ((tmp1 >> i) & 1) t ^= 1, tmp1 ^= 1 << i;
      if ((tmp2 >> i) & 1) {
        res ^= tmp1;
        if (t) res ^= 1 << i;
      }
    }
  }
  puts(res ? "Hamed" : "Malek");
  return 0;
}
int read() {
  int x = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    ;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
  return x;
}
