#include <bits/stdc++.h>
using namespace std;
struct {
  template <typename T>
  inline operator T() {
    T x = 0, f = 1;
    char c = getchar();
    while (!isdigit(c)) (c == '-') && (f = -1), c = getchar();
    while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f * x;
  }
} gi;
const int N = 100005, mK = 30;
int p[N][mK];
int cov[N << 2], lw[N << 2][mK];
void pushup(int o, int l, int r) {
  if (cov[o])
    for (int k = 0; k < mK; ++k) lw[o][k] = p[r][k] - p[l - 1][k];
  else if (l == r)
    for (int k = 0; k < mK; ++k) lw[o][k] = 0;
  else
    for (int k = 0; k < mK; ++k) lw[o][k] = lw[o << 1][k] + lw[o << 1 | 1][k];
}
void update(int o, int l, int r, int L, int R, int x) {
  if (L > r || l > R) return;
  if (L <= l && r <= R) return cov[o] += x, pushup(o, l, r);
  int mid = (l + r) >> 1;
  update(o << 1, l, mid, L, R, x), update(o << 1 | 1, mid + 1, r, L, R, x);
  pushup(o, l, r);
}
int ct[mK];
void gelw(int n) {
  fill(ct, ct + mK, 0);
  for (int k = mK - 1; k; k--) {
    ct[k - 1] += ct[k] << 1;
    if (n >> k & 1) ++ct[k - 1];
  }
  for (int k = 0; k < mK; k++)
    if (n >> k & 1) ++ct[k];
}
int v[mK];
struct Query {
  int l, r, t, o;
} q[N];
int t[N], tp;
int main() {
  int n = gi, m = gi, K = gi;
  n = 0;
  for (int k = 0; k < mK + 1; k++)
    if ((1 << k) > K) {
      K = 1 << k >> 1;
      break;
    }
  for (int i = 1; i <= m; i++) {
    int lx = gi, ly = gi;
    int rx = gi, ry = gi;
    q[i * 2 - 1] = {ly, ry, lx, 1};
    q[i * 2] = {ly, ry, rx + 1, -1};
    t[++n] = ly - 1;
    t[++n] = ry;
  }
  sort(t + 1, t + n + 1);
  n = unique(t + 1, t + n + 1) - t - 1;
  for (int i = 1; i <= n; i++) {
    gelw(t[i]);
    copy(ct, ct + mK, p[i]);
  }
  sort(q + 1, q + m * 2 + 1, [](Query a, Query b) { return a.t < b.t; });
  int sg = 0;
  for (int i = 1; i <= m * 2; i++) {
    gelw(q[i].t - 1);
    copy(ct, ct + mK, v);
    gelw(q[i - 1].t - 1);
    for (int k = 0; k < mK; k++) v[k] -= ct[k];
    for (int k = 0; k < mK; k++)
      if (v[k] & 1)
        for (int l = 0; l < mK; l++)
          if (lw[1][l] & 1) sg ^= min({1 << k, 1 << l, K});
    int l = lower_bound(t + 1, t + n + 1, q[i].l - 1) - t + 1;
    int r = lower_bound(t + 1, t + n + 1, q[i].r) - t;
    update(1, 1, n, l, r, q[i].o);
  }
  if (sg)
    puts("Hamed");
  else
    puts("Malek");
}
