#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int sz, nrect, maxmove;
int sr[50000], sc[50000], tr[50000], tc[50000];
int g[1000][1000];
bool any[1000][1000];
void show() {
  memset(any, false, sizeof(any));
  for (int i = (0); i < (nrect); ++i)
    for (int r = (sr[i]); r <= (tr[i]); ++r)
      for (int c = (sc[i]); c <= (tc[i]); ++c) any[r][c] = true;
  for (int i = (0); i < (sz); ++i)
    for (int j = (0); j < (sz); ++j) {
      long long mask = 0;
      for (int k = (1); k <= (maxmove); ++k) {
        if (i - k + 1 < 0 || j - k + 1 < 0) continue;
        int cur = 0;
        for (int ii = (0); ii < (k); ++ii)
          for (int jj = (0); jj < (k); ++jj)
            if (ii != k - 1 || jj != k - 1)
              cur ^= g[i - k + 1 + ii][j - k + 1 + jj];
        mask |= 1LL << cur;
      }
      g[i][j] = 0;
      while (mask & (1LL << g[i][j])) ++g[i][j];
    }
  int ret = 0, cnt = 0;
  for (int i = (0); i < (sz); ++i) {
    for (int j = (0); j < (sz); ++j)
      if (any[i + 1][j + 1])
        printf("%d", g[i][j]), ret ^= g[i][j], ++cnt;
      else
        printf("-");
    puts("");
  }
  printf("%d %d\n", ret, cnt);
}
typedef struct E {
  int x, ly, hy, type;
} E;
bool operator<(const E &a, const E &b) {
  if (a.x != b.x) return a.x < b.x;
  return false;
}
int ne;
E e[100000];
const int MAXS = 5000000;
int ns;
int lft[MAXS];
int rgt[MAXS];
int sval[MAXS];
int scnt[MAXS];
int create() {
  int ret = ns++;
  assert(ret < MAXS);
  lft[ret] = rgt[ret] = -1;
  sval[ret] = scnt[ret] = 0;
  return ret;
}
void update(int x, int l, int h) {
  if (sval[x] != 0) {
    scnt[x] = h - l + 1;
  } else {
    scnt[x] =
        (lft[x] != -1 ? scnt[lft[x]] : 0) + (rgt[x] != -1 ? scnt[rgt[x]] : 0);
  }
}
int get(int x, int l, int h) {
  if (x == -1) return 0;
  return scnt[x];
}
void change(int &x, int l, int h, int L, int H, int BY) {
  if (x == -1) x = create();
  if (L <= l && h <= H) {
    sval[x] += BY;
    update(x, l, h);
  } else {
    int m = l + (h - l) / 2;
    if (L <= m) change(lft[x], l, m, L, H, BY);
    if (m + 1 <= H) change(rgt[x], m + 1, h, L, H, BY);
    update(x, l, h);
  }
}
long long calc(int scale) {
  ne = 0;
  ns = 0;
  int root = -1, miny = 0, maxy = sz / scale;
  for (int i = (0); i < (nrect); ++i) {
    int sy = (sr[i] + scale - 1) / scale, ty = tr[i] / scale;
    int sx = (sc[i] + scale - 1) / scale, tx = tc[i] / scale;
    if (sy > ty || sx > tx) continue;
    e[ne].x = sx;
    e[ne].ly = sy;
    e[ne].hy = ty;
    e[ne].type = +1;
    ++ne;
    e[ne].x = tx + 1;
    e[ne].ly = sy;
    e[ne].hy = ty;
    e[ne].type = -1;
    ++ne;
  }
  sort(e, e + ne);
  long long ret = 0;
  for (int ei = (0); ei < (ne); ++ei) {
    if (ei != 0 && e[ei].x != e[ei - 1].x) {
      int dx = e[ei].x - e[ei - 1].x, dy = get(root, miny, maxy);
      ret += (long long)dx * dy;
    }
    change(root, miny, maxy, e[ei].ly, e[ei].hy, e[ei].type);
  }
  return ret;
}
long long pcnt[60];
void run() {
  scanf("%d%d%d", &sz, &nrect, &maxmove);
  for (int i = (0); i < (nrect); ++i) {
    scanf("%d%d%d%d", &sr[i], &sc[i], &tr[i], &tc[i]);
  }
  memset(pcnt, 0, sizeof(pcnt));
  for (int i = 0; (1 << i) <= maxmove; ++i) {
    pcnt[i] = calc(1 << i);
    if (i != 0) pcnt[i - 1] -= pcnt[i];
  }
  bool win = false;
  for (int i = (0); i < (60); ++i)
    if (pcnt[i] % 2 != 0) win = true;
  printf("%s\n", win ? "Hamed" : "Malek");
}
int main() {
  run();
  return 0;
}
