#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void ckmin(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
void ckmax(T &a, U b) {
  if (a < b) a = b;
}
int N, M, K;
pair<pair<int, int>, pair<int, int> > rect[100013];
vector<int> xs, ys;
int x[100013], y[100013], py[100013];
int lazy[3 * 100013];
pair<int, int> seg[3 * 100013];
vector<pair<pair<int, int>, int> > events[100013];
int ans;
pair<int, int> comb(pair<int, int> a, pair<int, int> b) {
  pair<int, int> res;
  res.first = min(a.first, b.first);
  res.second = (a.first == res.first ? a.second : 0) +
               (b.first == res.first ? b.second : 0);
  return res;
}
void build(int w, int L, int R) {
  lazy[w] = 0;
  seg[w] = {0, py[R + 1] - py[L]};
  if (L == R) return;
  int mid = (L + R) >> 1;
  build(w << 1, L, mid);
  build(w << 1 | 1, mid + 1, R);
}
void push(int w, int L, int R) {
  seg[w].first += lazy[w];
  if (L != R) {
    lazy[w << 1] += lazy[w];
    lazy[w << 1 | 1] += lazy[w];
  }
  lazy[w] = 0;
  return;
}
void update(int w, int L, int R, int a, int b, int v) {
  push(w, L, R);
  if (b < L || R < a) return;
  if (a <= L && R <= b) {
    lazy[w] += v;
    push(w, L, R);
    return;
  }
  int mid = (L + R) >> 1;
  update(w << 1, L, mid, a, b, v);
  update(w << 1 | 1, mid + 1, R, a, b, v);
  seg[w] = comb(seg[w << 1], seg[w << 1 | 1]);
}
int query() {
  return py[((int)((ys).size())) - 1] - (seg[1].first == 0 ? seg[1].second : 0);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M >> K;
  for (auto i = (0); i < (M); i++) {
    cin >> rect[i].first.first >> rect[i].first.second >>
        rect[i].second.first >> rect[i].second.second;
    rect[i].second.first++;
    rect[i].second.second++;
    xs.push_back(rect[i].first.first);
    xs.push_back(rect[i].second.first);
    ys.push_back(rect[i].first.second);
    ys.push_back(rect[i].second.second);
  }
  sort((xs).begin(), (xs).end());
  xs.erase(unique((xs).begin(), (xs).end()), xs.end());
  sort((ys).begin(), (ys).end());
  ys.erase(unique((ys).begin(), (ys).end()), ys.end());
  for (int pw = 1; pw <= K; pw <<= 1) {
    for (auto i = (0); i < (((int)((xs).size())) - 1); i++) {
      x[i] = (xs[i + 1] - 1) / pw - (xs[i] - 1) / pw;
      events[i].clear();
    }
    for (auto i = (0); i < (((int)((ys).size())) - 1); i++) {
      y[i] = (ys[i + 1] - 1) / pw - (ys[i] - 1) / pw;
      py[i + 1] = py[i] + y[i];
    }
    build(1, 0, ((int)((ys).size())) - 2);
    for (auto i = (0); i < (M); i++) {
      int x1 = rect[i].first.first, alksd = rect[i].first.second,
          x2 = rect[i].second.first, asdhfg = rect[i].second.second;
      alksd = lower_bound((ys).begin(), (ys).end(), alksd) - ys.begin();
      asdhfg = lower_bound((ys).begin(), (ys).end(), asdhfg) - ys.begin() - 1;
      events[lower_bound((xs).begin(), (xs).end(), x1) - xs.begin()].push_back(
          {{alksd, asdhfg}, 1});
      events[lower_bound((xs).begin(), (xs).end(), x2) - xs.begin()].push_back(
          {{alksd, asdhfg}, -1});
    }
    long long freq = 0;
    for (auto i = (0); i < (((int)((xs).size())) - 1); i++) {
      for (auto e : events[i]) {
        pair<int, int> p = e.first;
        int v = e.second;
        update(1, 0, ((int)((ys).size())) - 2, p.first, p.second, v);
      }
      long long sy = query();
      freq += sy * x[i];
    }
    if (freq & 1) {
      cout << "Hamed\n";
      return 0;
    }
  }
  cout << "Malek\n";
  return 0;
}
