#include <bits/stdc++.h>
using namespace std;
const int N = 100008;
int n, m, k, Q[N], mn[N * 4], lz[N * 4], cnt[N * 4];
pair<int, int> A[N], B[N];
vector<int> U;
void Init(int id = 1, int l = 0, int r = (int)U.size() - 1) {
  cnt[id] = U[r] - U[l];
  mn[id] = lz[id] = 0;
  if (r - l > 1)
    Init((id << 1), l, ((l + r) >> 1)), Init((id << 1 ^ 1), ((l + r) >> 1), r);
}
inline void Shift(int id) {
  lz[(id << 1)] += lz[id];
  mn[(id << 1)] += lz[id];
  lz[(id << 1 ^ 1)] += lz[id];
  mn[(id << 1 ^ 1)] += lz[id];
  lz[id] = 0;
}
void Add(int le, int ri, int val, int id = 1, int l = 0,
         int r = (int)U.size() - 1) {
  if (ri <= l || r <= le) return;
  if (le <= l && r <= ri) {
    lz[id] += val;
    mn[id] += val;
    return;
  }
  Shift(id);
  Add(le, ri, val, (id << 1), l, ((l + r) >> 1));
  Add(le, ri, val, (id << 1 ^ 1), ((l + r) >> 1), r);
  mn[id] = min(mn[(id << 1)], mn[(id << 1 ^ 1)]);
  cnt[id] = 0;
  if (mn[id] == mn[(id << 1)]) cnt[id] += cnt[(id << 1)];
  if (mn[id] == mn[(id << 1 ^ 1)]) cnt[id] += cnt[(id << 1 ^ 1)];
}
inline bool CMP(int i, int j) {
  int a = (i > 0) ? (A[i].first) : (B[-i].first);
  int b = (j > 0) ? (A[j].first) : (B[-j].first);
  if (a != b) return (a < b);
  return (i > j);
}
inline bool Solve() {
  U.clear();
  for (int i = 1; i <= m; i++) {
    U.push_back(A[i].second);
    Q[i + i - 1] = i;
    U.push_back(B[i].second);
    Q[i + i] = -i;
  }
  U.push_back(0);
  U.push_back(1000 * 1000 * 2000);
  sort(U.begin(), U.end());
  U.resize(unique(U.begin(), U.end()) - U.begin());
  sort(Q + 1, Q + m + m + 1, CMP);
  bool w = 0;
  int p = A[abs(Q[1])].first;
  Init();
  for (int i = 1; i <= m + m; i++) {
    int id = abs(Q[i]);
    int nw = (Q[i] > 0) ? (A[id].first) : (B[id].first);
    if (mn[1] == 0 && ((nw - p) & 1)) w ^= (cnt[1] & 1);
    int a = A[id].second;
    a = lower_bound(U.begin(), U.end(), A[id].second) - U.begin();
    int b = B[id].second;
    b = lower_bound(U.begin(), U.end(), B[id].second) - U.begin();
    if (Q[i] > 0) Add(a, b, 1);
    if (Q[i] < 0) Add(a, b, -1);
    p = nw;
  }
  return (w);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++)
    scanf("%d%d%d%d", &A[i].first, &A[i].second, &B[i].first, &B[i].second),
        B[i].first++, B[i].second++;
  for (int pw = 1; pw <= k; pw <<= 1) {
    if (Solve()) return !printf("Hamed");
    for (int i = 1; i <= m; i++) {
      A[i].first = (A[i].first + 1) >> 1;
      A[i].second = (A[i].second + 1) >> 1;
      B[i].first = (B[i].first + 1) >> 1;
      B[i].second = (B[i].second + 1) >> 1;
    }
  }
  return !printf("Malek");
}
