#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 85 - 69;
int r1[maxn], r2[maxn], c1[maxn], c2[maxn], segs[maxn * 4], segm[maxn * 4],
    laz[maxn * 4];
int n, m, k;
vector<int> xall, yall;
vector<pair<pair<int, int>, int> > quer[maxn];
void pull(int id) {
  int le = id << 1 | 0, ri = id << 1 | 1;
  segm[id] = min(segm[le], segm[ri]) + laz[id];
  segs[id] = 0;
  if (segm[le] <= segm[ri]) segs[id] += segs[le];
  if (segm[ri] <= segm[le]) segs[id] += segs[ri];
  return;
}
void build(int l = 0, int r = ((int)(yall).size()) - 1, int id = 1) {
  if (r - l < 1) return;
  segs[id] = yall[r] - yall[l];
  segm[id] = 0;
  laz[id] = 0;
  if (r - l == 1) return;
  int mid = (l + r) >> 1;
  build(l, mid, id << 1 | 0);
  build(mid, r, id << 1 | 1);
  return;
}
void add(int val, int st, int en, int l = 0, int r = ((int)(yall).size()) - 1,
         int id = 1) {
  if (st >= r or en <= l) return;
  if (st <= l and r <= en) {
    laz[id] += val;
    segm[id] += val;
    return;
  }
  int mid = (l + r) >> 1;
  add(val, st, en, l, mid, id << 1 | 0);
  add(val, st, en, mid, r, id << 1 | 1);
  pull(id);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) cin >> r1[i] >> c1[i] >> r2[i] >> c2[i];
  int high = 31 - __builtin_clz(k);
  for (int _ = 0; _ <= high; _++) {
    xall.clear();
    yall.clear();
    for (int i = 0; i < maxn; i++) quer[i].clear();
    for (int i = 0; i < m; i++) {
      xall.push_back(r1[i]);
      xall.push_back(r2[i] + 1);
      yall.push_back(c1[i]);
      yall.push_back(c2[i] + 1);
    }
    sort(xall.begin(), xall.end());
    sort(yall.begin(), yall.end());
    xall.resize(unique(xall.begin(), xall.end()) - xall.begin());
    yall.resize(unique(yall.begin(), yall.end()) - yall.begin());
    build();
    bool has = false;
    for (int i = 0; i < m; i++)
      if (c1[i] <= c2[i] and r1[i] <= r2[i]) {
        has = true;
        int xid = lower_bound(xall.begin(), xall.end(), r1[i]) - xall.begin();
        int lid = lower_bound(yall.begin(), yall.end(), c1[i]) - yall.begin(),
            rid =
                lower_bound(yall.begin(), yall.end(), c2[i] + 1) - yall.begin();
        quer[xid].push_back(make_pair(make_pair(lid, rid), +1));
        xid = lower_bound(xall.begin(), xall.end(), r2[i] + 1) - xall.begin();
        quer[xid].push_back(make_pair(make_pair(lid, rid), -1));
      }
    if (!has) break;
    int sum = 0;
    for (int i = 0; i < ((int)(xall).size()); i++) {
      for (auto Q : quer[i]) add(Q.second, Q.first.first, Q.first.second);
      if (i + 1 < ((int)(xall).size())) {
        int len = (xall[i + 1] - xall[i]) & 1;
        if (segm[1] == 0)
          sum += (len * (yall.back() - yall[0] - segs[1])) & 1;
        else
          sum += (len * (yall.back() - yall[0])) & 1;
      }
    }
    for (int i = 0; i < m; i++) {
      r1[i] = (r1[i] + 1) >> 1;
      c1[i] = (c1[i] + 1) >> 1;
      r2[i] >>= 1, c2[i] >>= 1;
    }
    sum &= 1;
    if (sum) {
      cout << "Hamed\n";
      return 0;
    }
  }
  cout << "Malek\n";
  return 0;
}
