#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void mine(T1 &x, const T2 &y) {
  if (y < x) x = y;
}
template <typename T1, typename T2>
inline void maxe(T1 &x, const T2 &y) {
  if (x < y) x = y;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &b) {
  for (auto &k : b) os << k << ' ';
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &b) {
  for (auto &k : b) is >> k;
  return is;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAX_MEM = 2e8;
char mem[MAX_MEM];
int mempos = 0;
inline void *operator new(size_t x) {
  if (mempos + x > MAX_MEM) mempos = 0;
  char *res = mem + mempos;
  mempos += x;
  return (void *)res;
}
inline void operator delete(void *) {}
namespace tree {
struct nd {
  int cl;
  int cr;
  int mn;
  int cnt;
  int add;
  nd *l;
  nd *r;
  nd(int _cl, int _cr)
      : cl(_cl), cr(_cr), mn(0), cnt(cr - cl), add(0), l(nullptr), r(nullptr) {}
};
void addv(nd *t, int x) {
  t->mn += x;
  t->add += x;
}
void push(nd *t) {
  int m = (t->cl + t->cr) / 2;
  if (!t->l) {
    t->l = new nd(t->cl, m);
  }
  if (!t->r) {
    t->r = new nd(m, t->cr);
  }
  addv(t->l, t->add);
  addv(t->r, t->add);
  t->add = 0;
}
void upd(nd *v, int l, int r, int x) {
  if (v->cl >= r || v->cr <= l) return;
  if (v->cl >= l && v->cr <= r) {
    addv(v, x);
    return;
  }
  push(v);
  upd(v->l, l, r, x);
  upd(v->r, l, r, x);
  v->mn = min(v->l->mn, v->r->mn);
  v->cnt = v->l->cnt * (v->l->mn == v->mn) + v->r->cnt * (v->r->mn == v->mn);
}
}  // namespace tree
struct act {
  int l;
  int r;
  int x;
  int d;
  act(int _l, int _r, int _x, int _d) {
    l = _l;
    r = _r;
    x = _x;
    d = _d;
  }
  bool operator<(const act &a) const { return x < a.x; }
};
const int M = 51234;
const int PW = 30;
long long c[PW];
int li[M];
int ri[M];
int lj[M];
int rj[M];
void win() {
  cout << "Hamed\n";
  exit(0);
}
void lose() {
  cout << "Malek\n";
  exit(0);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; ++i) {
    cin >> li[i] >> lj[i] >> ri[i] >> rj[i];
  }
  for (int i = 0; i < 32 - __builtin_clz(k); ++i) {
    vector<act> scan;
    for (int j = 0; j < m; ++j) {
      if (li[j] <= ri[j] && lj[j] <= rj[j]) {
        scan.push_back(act(lj[j], rj[j] + 1, li[j], 1));
        scan.push_back(act(lj[j], rj[j] + 1, ri[j] + 1, -1));
      }
      li[j] = (li[j] + 1) / 2;
      lj[j] = (lj[j] + 1) / 2;
      ri[j] /= 2;
      rj[j] /= 2;
    }
    sort(scan.begin(), scan.end());
    auto t = new tree::nd(1, n + 1);
    for (int j = 0; j < (int)scan.size(); ++j) {
      auto [l, r, x, delta] = scan[j];
      tree::upd(t, l, r, delta);
      int nx = (j + 1 == (int)scan.size() ? n : scan[j + 1].x);
      c[i] += 1ll * (nx - x) * (n - t->cnt * (t->mn == 0));
    }
    n /= 2;
  }
  for (long long i = PW - 1, sum = 0; i >= 0; sum += c[i--]) {
    c[i] -= sum;
    if (c[i] & 1) {
      win();
    }
  }
  lose();
}
