#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n, m, k, tot, g[N], tq;
long long ans[40];
class Rec {
 public:
  int X1, Y1, X2, Y2;
} a[N];
class Border {
 public:
  int l, r, pos, type;
} b[N];
void insert(int X1, int Y1, int X2, int Y2) {
  if (X1 > X2 || Y1 > Y2) return;
  g[++tq] = X1 - 1, g[++tq] = 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; }
class node {
 public:
  int l, r, cov, sum;
} tree[N << 2];
void build(int p, int l, int r) {
  tree[p].cov = tree[p].sum = 0;
  tree[p].l = l;
  tree[p].r = r;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build((p << 1), l, mid);
  build(((p << 1) | 1), mid + 1, r);
}
inline void update(int p) {
  if (tree[p].cov > 0) {
    tree[p].sum = g[tree[p].r] - g[tree[p].l - 1];
  } else {
    tree[p].sum = tree[(p << 1)].sum + tree[((p << 1) | 1)].sum;
  }
}
void Change(int p, int l, int r, int d) {
  if (tree[p].l >= l && tree[p].r <= r) {
    tree[p].cov += d;
    update(p);
    return;
  }
  int mid = (tree[p].l + tree[p].r) >> 1;
  if (l <= mid) {
    Change((p << 1), l, r, d);
  }
  if (r > mid) {
    Change(((p << 1) | 1), l, r, d);
  }
  update(p);
}
long long Solve(int num) {
  tq = tot = 0;
  long long ans = 0;
  for (int i = 1; i <= m; ++i) {
    insert((a[i].X1 - 1) / num + 1, (a[i].Y1 - 1) / num + 1, a[i].X2 / num,
           a[i].Y2 / num);
  }
  if (!tq) return 0;
  sort(g + 1, g + tq + 1);
  tq = unique(g + 1, g + tq + 1) - g - 1;
  for (int i = 1; i <= tot; ++i) {
    b[i].l = lower_bound(g + 1, g + tq + 1, b[i].l) - g;
    b[i].r = lower_bound(g + 1, g + tq + 1, b[i].r) - g;
  }
  build(1, 1, tq);
  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;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d%d", &a[i].X1, &a[i].Y1, &a[i].X2, &a[i].Y2);
  }
  for (int i = 0; i <= 30; ++i) {
    ans[i] = Solve(1 << i);
  }
  int tmp = 0;
  while ((1LL << (tmp + 1)) <= k) ++tmp;
  ans[tmp + 1] = 0;
  for (int i = 0; i <= tmp; ++i) {
    if ((ans[i] - ans[i + 1]) & 1) {
      puts("Hamed");
      return 0;
    }
  }
  puts("Malek");
  return 0;
}
