#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
struct node {
  int e[2], cnt[2], lazy;
  node() {
    e[0] = 0;
    e[1] = 0;
    cnt[0] = 0;
    cnt[1] = 0;
    lazy = 0;
  }
};
vector<int> z[MAXN];
vector<int> wx;
vector<int> wy;
node segt[4 * MAXN];
int x1[MAXN];
int x2[MAXN];
int u[MAXN];
int y2[MAXN];
int ex1[MAXN];
int ex2[MAXN];
int ey1[MAXN];
int ey2[MAXN];
node f;
int n, m;
node merge_node(node x, node y) {
  node res;
  res = x;
  if (res.e[0] == y.e[0]) {
    res.cnt[0] += y.cnt[0];
  }
  if (res.e[0] > y.e[0]) {
    res.e[0] = y.e[0];
    res.cnt[0] = y.cnt[0];
  }
  if (res.e[1] == y.e[1]) {
    res.cnt[1] += y.cnt[1];
  }
  if (res.e[1] > y.e[1]) {
    res.e[1] = y.e[1];
    res.cnt[1] = y.cnt[1];
  }
  res.lazy = 0;
  return res;
}
void lzu(int id) {
  for (int i = 1; i <= 2; i++) {
    segt[2 * id + i].e[0] += segt[id].lazy;
    segt[2 * id + i].e[1] += segt[id].lazy;
    segt[2 * id + i].lazy += segt[id].lazy;
  }
  segt[id].lazy = 0;
}
void build(int id, int L, int R) {
  if (L == R) {
    segt[id] = f;
    if (wx[L - 1] & 1) {
      segt[id].cnt[0] = (wx[L] - wx[L - 1] + 1) / 2;
      segt[id].cnt[1] = (wx[L] - wx[L - 1]) / 2;
      if (wx[L] - wx[L - 1] == 1) {
        segt[id].e[1] = 1;
      }
    } else {
      segt[id].cnt[0] = (wx[L] - wx[L - 1]) / 2;
      segt[id].cnt[1] = (wx[L] - wx[L - 1] + 1) / 2;
      if (wx[L] - wx[L - 1] == 1) {
        segt[id].e[0] = 1;
      }
    }
    return;
  }
  int mid = (L + R) / 2;
  build(2 * id + 1, L, mid);
  build(2 * id + 2, mid + 1, R);
  segt[id] = merge_node(segt[2 * id + 1], segt[2 * id + 2]);
}
void update(int id, int L, int R, int l, int r, int val) {
  if (L > r || R < l) {
    return;
  }
  if (L >= l && R <= r) {
    segt[id].e[0] += val;
    segt[id].e[1] += val;
    segt[id].lazy += val;
    return;
  }
  lzu(id);
  int mid = (L + R) / 2;
  update(2 * id + 1, L, mid, l, r, val);
  update(2 * id + 2, mid + 1, R, l, r, val);
  segt[id] = merge_node(segt[2 * id + 1], segt[2 * id + 2]);
}
int idx(int x) { return lower_bound(wx.begin(), wx.end(), x) - wx.begin() + 1; }
int idy(int x) { return lower_bound(wy.begin(), wy.end(), x) - wy.begin() + 1; }
void solve(bool b) {
  wx.clear();
  wy.clear();
  for (int i = 0; i < MAXN; i++) {
    z[i].clear();
  }
  for (int i = 1; i <= m; i++) {
    wx.push_back(x1[i]);
    wx.push_back(x2[i] + 1);
    wy.push_back(u[i]);
    wy.push_back(y2[i] + 1);
  }
  wx.push_back(1);
  wx.push_back(n);
  wx.push_back(n + 1);
  sort(wx.begin(), wx.end());
  wx.resize(unique(wx.begin(), wx.end()) - wx.begin());
  sort(wy.begin(), wy.end());
  wy.resize(unique(wy.begin(), wy.end()) - wy.begin());
  for (int i = 1; i <= m; i++) {
    ex1[i] = idx(x1[i]);
    ex2[i] = idx(x2[i] + 1) - 1;
    ey1[i] = idy(u[i]);
    ey2[i] = idy(y2[i] + 1);
    z[ey1[i]].push_back(i);
    z[ey2[i]].push_back(-i);
  }
  build(0, 1, (int)(wx.size()) - 1);
  int res = 0;
  for (int i = 1; i <= (int)(wy.size()); i++) {
    for (int j = 0; j < z[i].size(); j++) {
      if (z[i][j] > 0) {
        update(0, 1, (int)(wx.size()) - 1, ex1[z[i][j]], ex2[z[i][j]], 1);
      } else {
        update(0, 1, (int)(wx.size()) - 1, ex1[-z[i][j]], ex2[-z[i][j]], -1);
      }
    }
    if (i < (int)(wy.size())) {
      int d = 0, p = 0, cnt_d = 0, cnt_p = 0;
      d = ((n + 1) / 2) - (segt[0].e[0] == 0 ? segt[0].cnt[0] : 0);
      p = (n / 2) - (segt[0].e[1] == 0 ? segt[0].cnt[1] : 0);
      if (wy[i - 1] & 1) {
        cnt_d = (wy[i] - wy[i - 1] + 1) / 2;
        cnt_p = (wy[i] - wy[i - 1]) / 2;
      } else {
        cnt_d = (wy[i] - wy[i - 1]) / 2;
        cnt_p = (wy[i] - wy[i - 1] + 1) / 2;
      }
      d = (d & 1);
      p = (p & 1);
      cnt_d = (cnt_d & 1);
      cnt_p = (cnt_p & 1);
      if (b) {
        res += d * (cnt_d + cnt_p) + p * (cnt_d + cnt_p);
      } else {
        res += d * (cnt_d + cnt_p) + p * cnt_d;
      }
    }
  }
  if (res & 1) {
    cout << "Hamed";
    exit(0);
  }
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    cin >> x1[i] >> u[i] >> x2[i] >> y2[i];
  }
  while (k > 0 && n >= 1) {
    solve(k == 1);
    for (int i = 1; i <= m; i++) {
      x1[i] += (x1[i] & 1);
      u[i] += (u[i] & 1);
      x2[i] -= (x2[i] & 1);
      y2[i] -= (y2[i] & 1);
      x1[i] /= 2;
      u[i] /= 2;
      x2[i] /= 2;
      y2[i] /= 2;
    }
    k /= 2;
    n /= 2;
  }
  cout << "Malek";
}
