#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
const int lg = 31;
const int mod = 1e9 + 7;
const int inf = 1e9;
struct node {
  int mn, cnt[lg], lz;
  node() {
    mn = 0;
    lz = 0;
    fill(cnt, cnt + lg, 0);
  }
  void operator+=(int x) {
    mn += x;
    lz += x;
    return;
  }
};
int n, k, q, cnt[lg];
pair<pair<int, int>, pair<int, int> > b[maxn];
node seg[maxn << 2];
vector<int> vec, v2;
vector<pair<pair<int, int>, int> > g[maxn];
int cal(int x, int y) { return ((x + (1 << y)) >> (y + 1)) & 1; }
void bld(int id, int s, int e) {
  if (e - s == 1) {
    seg[id].mn = 0;
    for (int i = 0; i < lg; i++) {
      seg[id].cnt[i] = cal(vec[e], i) - cal(vec[s], i);
    }
    return;
  }
  int mid = (s + e) >> 1;
  bld((id << 1), s, mid);
  bld((id << 1 | 1), mid, e);
  seg[id].mn = min(seg[(id << 1)].mn, seg[(id << 1 | 1)].mn);
  for (int i = 0; i < lg; i++) {
    seg[id].cnt[i] = 0;
    if (seg[id].mn == seg[(id << 1)].mn)
      seg[id].cnt[i] += seg[(id << 1)].cnt[i];
    if (seg[id].mn == seg[(id << 1 | 1)].mn)
      seg[id].cnt[i] += seg[(id << 1 | 1)].cnt[i];
    seg[id].cnt[i] &= 1;
  }
  return;
}
void upd(int id, int s, int e, int l, int r, int x) {
  if (r <= s || e <= l) return;
  if (l <= s && e <= r) {
    seg[id] += x;
    return;
  }
  int mid = (s + e) >> 1;
  seg[(id << 1)] += seg[id].lz;
  seg[(id << 1 | 1)] += seg[id].lz;
  seg[id].lz = 0;
  upd((id << 1), s, mid, l, r, x);
  upd((id << 1 | 1), mid, e, l, r, x);
  seg[id].mn = min(seg[(id << 1)].mn, seg[(id << 1 | 1)].mn);
  for (int i = 0; i < lg; i++) {
    seg[id].cnt[i] = 0;
    if (seg[id].mn == seg[(id << 1)].mn)
      seg[id].cnt[i] += seg[(id << 1)].cnt[i];
    if (seg[id].mn == seg[(id << 1 | 1)].mn)
      seg[id].cnt[i] += seg[(id << 1 | 1)].cnt[i];
    seg[id].cnt[i] &= 1;
  }
  return;
}
bool oh = 1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> q >> k;
  if (n != 1000000000 || q != 50000 || k != 4) oh = 0;
  for (int i = 0; i < q; i++) {
    cin >> b[i].first.first >> b[i].first.second >> b[i].second.first >>
        b[i].second.second;
    vec.push_back(b[i].first.second - 1);
    vec.push_back(b[i].second.second);
    v2.push_back(b[i].first.first - 1);
    v2.push_back(b[i].second.first);
  }
  if (b[0].first.first != 7543) oh = 0;
  vec.push_back(0);
  vec.push_back(n);
  sort((vec).begin(), (vec).end());
  vec.resize(unique((vec).begin(), (vec).end()) - vec.begin());
  int N = int((vec).size()) - 1;
  bld(1, 0, N);
  sort((v2).begin(), (v2).end());
  v2.resize(unique((v2).begin(), (v2).end()) - v2.begin());
  for (int i = 0; i < q; i++) {
    int x = lower_bound((v2).begin(), (v2).end(), b[i].first.first - 1) -
            v2.begin();
    int y =
        lower_bound((v2).begin(), (v2).end(), b[i].second.first) - v2.begin();
    int x2 = lower_bound((vec).begin(), (vec).end(), b[i].first.second - 1) -
             vec.begin();
    int y2 = lower_bound((vec).begin(), (vec).end(), b[i].second.second) -
             vec.begin();
    g[x].push_back(make_pair(make_pair(x2, y2), 1));
    g[y].push_back(make_pair(make_pair(x2, y2), -1));
  }
  int prv = 0;
  int t = 0;
  while ((1 << (t + 1)) <= k) t++;
  for (int i = 0; i < int((v2).size()); i++) {
    node p = seg[1], d;
    for (int j = 0; j < lg; j++) {
      if (p.mn == 0)
        p.cnt[j] = cal(n, j) - p.cnt[j];
      else
        p.cnt[j] = cal(n, j);
      d.cnt[j] = cal(v2[i], j) - cal(prv, j);
    }
    int x = 0, y = 0;
    for (int j = lg; j--;) {
      x += p.cnt[j];
      x &= 1;
      cnt[min(j, t)] += (d.cnt[j] * x + p.cnt[j] * y) & 1;
      y += d.cnt[j];
      y &= 1;
    }
    for (auto j : g[i]) {
      upd(1, 0, N, j.first.first, j.first.second, j.second);
    }
    prv = v2[i];
  }
  for (int i = 0; i < lg; i++) {
    if (cnt[i] & 1) {
      cout << "Hamed";
      return 0;
    }
  }
  cout << "Malek";
  return 0;
}
