#include <bits/stdc++.h>
using namespace std;
long long n, k;
set<long long> s;
vector<long long> v[10];
long long vbm[10];
long long vbmf[10][41];
vector<long long> vn[10];
void test(long long i, long long b) {
  if (i == k) {
    bool one = false;
    for (long long j = 0; j < n; ++j) {
      if (b & ((long long)1 << j)) {
        one = true;
      } else if (one) {
        cout << "REJECTED\n";
        exit(0);
      }
    }
    return;
  }
  for (long long r = 0; r <= (long long)vn[i].size(); ++r) {
    long long cnt = r + __builtin_popcountll(b & vbm[i]);
    long long c = (b & ~vbm[i]) ^ vbmf[i][cnt];
    test(i + 1, c);
  }
}
int32_t main() {
  cin >> n >> k;
  for (long long i = 0; i < k; ++i) {
    long long q;
    cin >> q;
    for (long long j = 0; j < q; ++j) {
      long long a;
      cin >> a;
      a--;
      v[i].push_back(a);
      vbm[i] |= (long long)1 << a;
      for (long long r = q - j; r <= q; ++r) vbmf[i][r] |= (long long)1 << a;
      if (s.count(a) == 0) vn[i].push_back(a);
      s.insert(a);
    }
  }
  if (n == 1) {
    cout << "ACCEPTED\n";
    return 0;
  }
  if ((long long)s.size() != n) {
    cout << "REJECTED\n";
    return 0;
  }
  test(0, 0);
  cout << "ACCEPTED\n";
}
