#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long a = 0, fh = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') fh = -1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    a = a * 10 + c - 48;
    c = getchar();
  }
  return a * fh;
}
long long T, n, m;
long long k[300005], vis[300005];
vector<long long> p[300005];
vector<pair<long long, long long> > e[300005];
pair<long long, long long> fk[300005];
signed main() {
  T = read();
  while (T--) {
    n = read();
    m = read();
    for (long long i = 1; i <= n; ++i) e[i].clear();
    long long S = 0;
    for (long long i = 1; i <= m; ++i) {
      p[i].resize(k[i] = read());
      S += k[i];
      for (long long j = 0; j < p[i].size(); ++j) p[i][j] = read();
    }
    long long blk = sqrt(S), ok = 0;
    for (long long i = 1; i <= m && !ok; ++i) {
      if (k[i] >= blk) {
        for (long long j = 1; j <= n; ++j) vis[j] = -1;
        for (long long j = 0; j < p[i].size(); ++j) vis[p[i][j]] = j;
        for (long long j = 1; j <= m && !ok; ++j) {
          if (j <= i && k[j] >= blk) continue;
          long long mx = vis[p[j].back()];
          for (long long o = (long long)p[j].size() - 2; o >= 0; --o) {
            if (vis[p[j][o]] != -1 && vis[p[j][o]] <= mx &&
                vis[p[j][o]] != p[i].size() - 1) {
              if (p[j][o + 1] != p[i][vis[p[j][o]] + 1]) {
                ok = 1;
                break;
              }
            }
            mx = max(mx, vis[p[j][o]]);
          }
        }
      } else {
        for (long long j = 0; j < p[i].size(); ++j)
          for (long long k = j + 1; k < p[i].size(); ++k) {
            e[p[i][j]].push_back(make_pair(p[i][k], p[i][j + 1]));
          }
      }
    }
    if (!ok) {
      for (long long i = 1; i <= n; ++i) fk[i] = make_pair(0, 0);
      for (long long i = 1; i <= n && !ok; ++i) {
        for (long long j = 0; j < e[i].size(); ++j) {
          long long v = e[i][j].first, w = e[i][j].second;
          if (fk[v].first != i)
            fk[v] = make_pair(i, w);
          else if (fk[v].second != w) {
            ok = 1;
            break;
          }
        }
      }
    }
    puts(ok ? "Human" : "Robot");
  }
  return 0;
}
