#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  register long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return (f == 1) ? x : -x;
}
inline void file() {
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
}
int n, m, k, tot, g[202020], qwq;
long long ans[44];
struct Rec {
  int X1, Y1, X2, Y2;
} a[202020];
struct Border {
  int l, r, pos, type;
} b[202020];
void Insert(int X1, int Y1, int X2, int Y2) {
  if (X1 > X2 || Y1 > Y2) return;
  g[++qwq] = X1 - 1, g[++qwq] = X2;
  b[++tot] = {X1, X2, Y1, 1};
  b[++tot] = {X1, X2, Y2 + 1, -1};
}
bool cmp(Border a, Border b) { return a.pos < b.pos; }
struct node {
  int l, r, cov, sum;
} tree[808080];
void build(int i, int l, int r) {
  tree[i].cov = tree[i].sum = 0;
  tree[i].l = l, tree[i].r = r;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(i << 1, l, mid);
  build(i << 1 | 1, mid + 1, r);
}
inline void update(int i) {
  if (tree[i].cov > 0)
    tree[i].sum = g[tree[i].r] - g[tree[i].l - 1];
  else
    tree[i].sum = tree[i << 1].sum + tree[i << 1 | 1].sum;
}
void Change(int i, int l, int r, int d) {
  if (tree[i].l >= l && tree[i].r <= r) {
    tree[i].cov += d;
    update(i);
    return;
  }
  int mid = (tree[i].l + tree[i].r) >> 1;
  if (l <= mid) Change(i << 1, l, r, d);
  if (r > mid) Change(i << 1 | 1, l, r, d);
  update(i);
}
inline long long solve(int now) {
  qwq = tot = 0;
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    Insert((a[i].X1 - 1) / now + 1, (a[i].Y1 - 1) / now + 1, a[i].X2 / now,
           a[i].Y2 / now);
  }
  if (!qwq) return 0;
  sort(g + 1, g + qwq + 1);
  qwq = unique(g + 1, g + qwq + 1) - g - 1;
  for (int i = 1; i <= tot; i++) {
    b[i].l = lower_bound(g + 1, g + qwq + 1, b[i].l) - g;
    b[i].r = lower_bound(g + 1, g + qwq + 1, b[i].r) - g;
  }
  build(1, 1, qwq);
  sort(b + 1, b + tot + 1, cmp);
  for (int i = 1, j = 1; i <= tot; i = j) {
    ans += tree[1].sum * (b[i].pos - b[i - 1].pos);
    while (b[i].pos == b[j].pos && j <= tot) {
      Change(1, b[j].l, b[j].r, b[j].type);
      ++j;
    }
  }
  return ans;
}
signed main() {
  n = read(), m = read(), k = read();
  for (int i = 1; i <= m; ++i) {
    a[i].X1 = read(), a[i].Y1 = read(), a[i].X2 = read(), a[i].Y2 = read();
  }
  int len = 0;
  while ((1ll << (len + 1)) <= k) ++len;
  for (int i = 0; i <= len; i++) ans[i] = solve(1ll << i);
  for (int i = 0; i <= len; i++) {
    if ((ans[i] - ans[i + 1]) & 1ll) {
      puts("Hamed");
      return 0;
    }
  }
  puts("Malek");
  return 0;
}
