#include <bits/stdc++.h>
using namespace std;
int x[123456], y[123456], xx[123456], yy[123456];
int arr[123456 * 4];
struct seg {
  int x, st, ed, v;
  seg(int x, int st, int ed, int v) : x(x), st(st), ed(ed), v(v){};
  seg(){};
} s[123456 * 3];
bool cmp(seg u, seg v) {
  if (u.x == v.x) return u.v > v.v;
  return u.x < v.x;
}
int mn[123456 * 4], cnt[123456 * 4], flag[123456 * 4];
void push_up(int u) {
  mn[u] = min(mn[(u << 1)], mn[((u << 1) + 1)]);
  cnt[u] = (mn[u] == mn[(u << 1)]) * cnt[(u << 1)] +
           (mn[u] == mn[((u << 1) + 1)]) * cnt[((u << 1) + 1)];
}
void build(int u, int st, int ed) {
  flag[u] = 0;
  if (ed == st + 1) {
    mn[u] = 0;
    cnt[u] = arr[ed] - arr[st];
    return;
  }
  build((u << 1), st, ((st + ed) >> 1));
  build(((u << 1) + 1), ((st + ed) >> 1), ed);
  push_up(u);
}
void push_down(int u) {
  if (flag[u] == 0) return;
  mn[(u << 1)] += flag[u];
  mn[((u << 1) + 1)] += flag[u];
  flag[(u << 1)] += flag[u];
  flag[((u << 1) + 1)] += flag[u];
  flag[u] = 0;
}
void update(int u, int st, int ed, int l, int r, int d) {
  l = max(l, st);
  r = min(r, ed);
  if (l >= r) return;
  if (st == l && ed == r) {
    mn[u] += d;
    flag[u] += d;
    return;
  }
  push_down(u);
  update((u << 1), st, ((st + ed) >> 1), l, r, d);
  update(((u << 1) + 1), ((st + ed) >> 1), ed, l, r, d);
  push_up(u);
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d %d", x + i, y + i, xx + i, yy + i);
    x[i]--;
    y[i]--;
  }
  while (k) {
    int nn = 0;
    for (int i = 0; i < m; i++) {
      arr[nn++] = y[i];
      arr[nn++] = yy[i];
    }
    sort(arr, arr + nn);
    nn = unique(arr, arr + nn) - arr;
    int ns = 0;
    for (int i = 0; i < m; i++) {
      int st = lower_bound(arr, arr + nn, y[i]) - arr;
      int ed = lower_bound(arr, arr + nn, yy[i]) - arr;
      s[ns++] = seg(x[i], st, ed, 1);
      s[ns++] = seg(xx[i], st, ed, -1);
    }
    sort(s, s + ns, cmp);
    arr[nn] = arr[nn - 1];
    build(1, 0, nn);
    long long ans = 0;
    for (int i = 0; i < ns; i++) {
      if (i)
        ans += (long long)(s[i].x - s[i - 1].x) *
               (arr[nn - 1] - arr[0] - (mn[1] == 0) * cnt[1]);
      update(1, 0, nn, s[i].st, s[i].ed, s[i].v);
    }
    if (ans & 1LL) return puts("Hamed");
    for (int i = 0; i < m; i++) {
      x[i] >>= 1;
      y[i] >>= 1;
      xx[i] >>= 1;
      yy[i] >>= 1;
    }
    k >>= 1;
  }
  puts("Malek");
  return 0;
}
