#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7FFFFFFF;
const int MAXN = 131072;
int ycoord[MAXN];
class Tree {
  int n;
  int qadd[MAXN * 2];
  int qmin[MAXN * 2];
  int qsum[MAXN * 2];
  void int_push(int v) {
    qadd[v + v] += qadd[v];
    qmin[v + v] += qadd[v];
    qadd[v + v + 1] += qadd[v];
    qmin[v + v + 1] += qadd[v];
    qadd[v] = 0;
  }
  void int_add(int v, int x, int L, int R, int tl, int tr) {
    if (L <= tl && R >= tr) {
      qadd[v] += x;
      qmin[v] += x;
      return;
    } else if (v >= MAXN)
      return;
    int_push(v);
    int tm = (tl + tr) / 2;
    if (L < tm) int_add(v + v, x, L, R, tl, tm);
    if (R > tm) int_add(v + v + 1, x, L, R, tm, tr);
    qmin[v] = min(qmin[v + v], qmin[v + v + 1]);
    qsum[v] = 0;
    if (qmin[v + v] == qmin[v]) qsum[v] += qsum[v + v];
    if (qmin[v + v + 1] == qmin[v]) qsum[v] += qsum[v + v + 1];
  }

 public:
  void build(int n_) {
    n = n_ - 1;
    memset(qmin, 0, sizeof qmin);
    memset(qadd, 0, sizeof qadd);
    memset(qsum, 0, sizeof qsum);
    for (int i = (0); i < (n); i++) qsum[i + MAXN] = ycoord[i + 1] - ycoord[i];
    for (int i = (MAXN)-1; i >= 1; i--) qsum[i] = qsum[i + i] + qsum[i + i + 1];
    qsum[0] = qsum[1];
  }
  void add(int l, int r, int x) {
    l = lower_bound(ycoord, ycoord + n + 1, l) - ycoord;
    r = lower_bound(ycoord, ycoord + n + 1, r) - ycoord;
    int_add(1, x, l, r, 0, MAXN);
  }
  int get() { return qsum[0] - (qmin[1] ? 0 : qsum[1]); }
};
Tree tree;
struct Rect {
  int x1, y1, x2, y2;
};
Rect rects[MAXN];
pair<int, pair<pair<int, int>, int>> events[MAXN];
int area(int n, int s) {
  int ne = 0, ny = 0;
  for (int i = (0); i < (n); i++) {
    events[ne++] = pair<int, pair<pair<int, int>, int>>(
        (rects[i].x1 + s - 1) / s,
        make_pair(
            pair<int, int>((rects[i].y1 + s - 1) / s, rects[i].y2 / s + 1),
            +1));
    events[ne++] = pair<int, pair<pair<int, int>, int>>(
        rects[i].x2 / s + 1, make_pair(pair<int, int>((rects[i].y1 + s - 1) / s,
                                                      rects[i].y2 / s + 1),
                                       -1));
    ycoord[ny++] = events[ne - 1].second.first.first;
    ycoord[ny++] = events[ne - 1].second.first.second;
  }
  sort(events, events + ne);
  sort(ycoord, ycoord + ny);
  ny = unique(ycoord, ycoord + ny) - ycoord;
  tree.build(ny);
  int sum = 0;
  for (int i = (0); i < (ne); i++) {
    if (i) sum += (events[i].first - events[i - 1].first) * tree.get();
    tree.add(events[i].second.first.first, events[i].second.first.second,
             events[i].second.second);
  }
  return sum;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = (0); i < (m); i++)
    cin >> rects[i].x1 >> rects[i].y1 >> rects[i].x2 >> rects[i].y2;
  for (int s = 0; (1 << s) <= k; s++) {
    if (area(m, 1 << s) & 1) {
      cout << "Hamed";
      return 0;
    }
  }
  cout << "Malek";
  return 0;
}
