#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
const long double pi = acos(-1.0);
const int N = 2 * 55555;
int n, m, k, res, rmq[4 * N], upd[4 * N], x1[N], __LOVE__[N], x2[N], y2[N];
vector<int> ally;
vector<pair<pair<int, int>, pair<int, int> > > e;
void update(int t, int l, int r, int x, int y, int delta) {
  if ((y <= l) || (r <= x)) return;
  if ((x <= l) && (r <= y)) {
    rmq[t] = (l == r - 1) ? 0 : (rmq[t * 2 + 1] + rmq[t * 2 + 2]);
    if ((upd[t] += delta) > 0) rmq[t] = ally[r] - ally[l];
  } else {
    int m = (l + r) / 2;
    update(t * 2 + 1, l, m, x, y, delta);
    update(t * 2 + 2, m, r, x, y, delta);
    rmq[t] = rmq[t * 2 + 1] + rmq[t * 2 + 2];
    if (upd[t] > 0) rmq[t] = ally[r] - ally[l];
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < m; ++i)
    scanf("%d%d%d%d", &x1[i], &__LOVE__[i], &x2[i], &y2[i]), x2[i]++, y2[i]++;
  for (int size = 1; size <= k; size *= 2) {
    ally.clear();
    e.clear();
    for (int i = 0; i < m; ++i) {
      int xl = (x1[i] + size - 1) / size, xr = (x2[i] + size - 1) / size,
          yl = (__LOVE__[i] + size - 1) / size, yr = (y2[i] + size - 1) / size;
      ally.push_back(yl), ally.push_back(yr);
      e.push_back(make_pair(make_pair(xl, +1), make_pair(yl, yr)));
      e.push_back(make_pair(make_pair(xr, -1), make_pair(yl, yr)));
    }
    ally.push_back(n + 1);
    sort(ally.begin(), ally.end());
    ally.resize(unique(ally.begin(), ally.end()) - ally.begin());
    sort(e.begin(), e.end());
    long long sum = 0;
    for (int i = 0; i < ((int)(e).size()); ++i) {
      int l = lower_bound(ally.begin(), ally.end(), e[i].second.first) -
              ally.begin();
      int r = lower_bound(ally.begin(), ally.end(), e[i].second.second) -
              ally.begin();
      update(0, 0, ((int)(ally).size()), l, r, e[i].first.second);
      if (i != ((int)(e).size()) - 1)
        sum += rmq[0] * (e[i + 1].first.first - e[i].first.first);
    }
    if (sum & 1) res ^= (size ^ (size / 2));
  }
  printf(res ? "Hamed\n" : "Malek\n");
  return 0;
}
