#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
struct modint {
  int x;
  modint(int o = 0) { x = o; }
  modint &operator=(int o) { return x = o, *this; }
  modint &operator+=(modint o) {
    return x = x + o.x >= 998244353 ? x + o.x - 998244353 : x + o.x, *this;
  }
  modint &operator-=(modint o) {
    return x = x - o.x < 0 ? x - o.x + 998244353 : x - o.x, *this;
  }
  modint &operator*=(modint o) { return x = 1ll * x * o.x % 998244353, *this; }
  modint &operator^=(int b) {
    modint a = *this, c = 1;
    for (; b; b >>= 1, a *= a)
      if (b & 1) c *= a;
    return x = c.x, *this;
  }
  modint &operator/=(modint o) { return *this *= o ^= 998244353 - 2; }
  modint &operator+=(int o) {
    return x = x + o >= 998244353 ? x + o - 998244353 : x + o, *this;
  }
  modint &operator-=(int o) {
    return x = x - o < 0 ? x - o + 998244353 : x - o, *this;
  }
  modint &operator*=(int o) { return x = 1ll * x * o % 998244353, *this; }
  modint &operator/=(int o) { return *this *= ((modint(o)) ^= 998244353 - 2); }
  template <class I>
  friend modint operator+(modint a, I b) {
    return a += b;
  }
  template <class I>
  friend modint operator-(modint a, I b) {
    return a -= b;
  }
  template <class I>
  friend modint operator*(modint a, I b) {
    return a *= b;
  }
  template <class I>
  friend modint operator/(modint a, I b) {
    return a /= b;
  }
  friend modint operator^(modint a, int b) { return a ^= b; }
  friend bool operator==(modint a, int b) { return a.x == b; }
  friend bool operator!=(modint a, int b) { return a.x != b; }
  bool operator!() { return !x; }
  modint operator-() { return x ? 998244353 - x : 0; }
};
int n, k;
vector<int> q[200005];
bool vis[45], now[45];
void solve(int st) {
  if (st == k + 1) {
    for (register int i = (1); i <= (n); ++i) {
      if (!vis[i]) {
        puts("REJECTED");
        exit(0);
      }
      if (i != 1 && now[i] < now[i - 1]) {
        puts("REJECTED");
        exit(0);
      }
    }
    return;
  }
  int len = q[st].size();
  int cnt1 = 0, cnt0 = 0;
  bool lstn[45], lstv[45];
  for (register int i = (1); i <= (n); ++i) lstn[i] = now[i], lstv[i] = vis[i];
  for (auto x : q[st])
    if (vis[x])
      cnt1 += (now[x]), cnt0 += (!now[x]);
    else
      vis[x] = 1;
  for (register int i = (0); i <= (len - cnt1 - 1); ++i) now[q[st][i]] = 0;
  for (register int i = (len - cnt1); i <= (len - 1); ++i) now[q[st][i]] = 1;
  for (register int i = (cnt1); i <= (len - cnt0); ++i) {
    solve(st + 1);
    if (i != len - cnt0) now[q[st][len - i - 1]] = 1;
  }
  for (register int i = (1); i <= (n); ++i) now[i] = lstn[i], vis[i] = lstv[i];
}
signed main() {
  srand(time(0));
  n = read(), k = read();
  if (n == 1) {
    puts("ACCEPTED");
    return 0;
  }
  for (register int i = (1); i <= (k); ++i) {
    int sz = read();
    q[i].resize(sz);
    for (register int j = (0); j <= (sz - 1); ++j) q[i][j] = read();
  }
  solve(1);
  puts("ACCEPTED");
  return 0;
}
