#include <bits/stdc++.h>
using namespace std;
const int N = 41, K = 11;
bitset<40> a[N];
vector<int> steps[K];
int n, k;
bool ok = true;
void go(int pos, bitset<40> is_one, bitset<40> is_question) {
  if (pos == k) {
    if (is_question != 0) {
      ok = false;
      return;
    }
    int ones = is_one.count();
    if (is_one != a[ones]) {
      ok = false;
      return;
    }
    return;
  }
  int ones = 0, zeros = 0, questions = 0;
  for (int i : steps[pos]) {
    if (is_question[i]) {
      questions++;
    } else if (is_one[i]) {
      ones++;
    } else {
      zeros++;
    }
    is_question[i] = 0;
    is_one[i] = 1;
  }
  for (int i = 0; i < zeros; i++) {
    is_one[steps[pos][i]] = 0;
  }
  go(pos + 1, is_one, is_question);
  for (int i = zeros; i < questions + zeros; i++) {
    is_one[steps[pos][i]] = 0;
    go(pos + 1, is_one, is_question);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int _ = 1;
  while (_--) {
    cin >> n >> k;
    for (int i = 0; i <= n; i++) {
      a[i] = 0;
      for (int j = 0; j < i; j++) {
        a[i][n - j - 1] = 1;
      }
    }
    for (int i = 0; i < k; i++) {
      int q;
      cin >> q;
      while (q--) {
        int x;
        cin >> x;
        steps[i].push_back(--x);
      }
    }
    bitset<40> is_one = 0;
    bitset<40> is_question = (1ll << n) - 1;
    go(0, is_one, is_question);
    cout << (n == 1 || ok ? "ACCEPTED" : "REJECTED") << endl;
  }
}
