#include <bits/stdc++.h>
using namespace std;
vector<long long> swaps;
long long lenArray, nbSwaps;
void test(long long curSwap, long long maskSeen, long long maskVal) {
  if (curSwap == nbSwaps) {
    for (long long i = 0; i < lenArray; ++i)
      if (!((1LL << i) & maskSeen)) {
        cout << "REJECTED";
        cout << endl;
        exit(0);
      }
    bool seen1 = false;
    for (long long i = 0; i < lenArray; ++i) {
      if ((1LL << i) & maskVal)
        seen1 = true;
      else if (seen1) {
        cout << "REJECTED";
        cout << endl;
        exit(0);
      }
    }
    return;
  }
  long long cntUnset = __builtin_popcountll(~maskSeen & swaps[curSwap]);
  long long cnt1 = __builtin_popcountll(maskVal & swaps[curSwap]);
  long long cnt0 = __builtin_popcountll(swaps[curSwap]) - cnt1 - cntUnset;
  long long nxtVal = maskVal | swaps[curSwap];
  long long nxtSeen = maskSeen | swaps[curSwap];
  long long cur = 0;
  long long nbVus = 0;
  while (nbVus < cnt0) {
    if ((1LL << cur) & swaps[curSwap]) {
      nbVus++;
      nxtVal ^= 1LL << cur;
    }
    ++cur;
  }
  for (long long add0 = 0; add0 <= cntUnset; ++add0) {
    assert(__builtin_popcountll(nxtVal & swaps[curSwap]) ==
           __builtin_popcountll(swaps[curSwap]) - cnt0 - add0);
    test(curSwap + 1, nxtSeen, nxtVal);
    if (add0 < cntUnset) {
      while (!((1LL << cur) & swaps[curSwap])) ++cur;
      assert(cur < lenArray);
      nxtVal -= 1LL << cur++;
    }
  }
}
signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> lenArray >> nbSwaps;
  if (lenArray == 1) {
    cout << "ACCEPTED\n";
    return 0;
  }
  swaps.resize(nbSwaps);
  for (long long i = 0; i < nbSwaps; ++i) {
    long long l;
    cin >> l;
    for (long long j = 0; j < l; ++j) {
      long long x;
      cin >> x;
      swaps[i] |= 1LL << (x - 1);
    }
  }
  test(0, 0, 0);
  cout << "ACCEPTED\n";
}
