Andrea has come up with what he believes to be a novel sorting algorithm for arrays of length n. The algorithm works as follows.

Initially there is an array of n integers a_1,  a_2,  ...,  a_n. Then, k steps are executed.

For each 1≤ i≤ k, during the i-th step the subsequence of the array a with indexes j_{i,1}< j_{i,2}< ...< j_{i, q_i} is sorted, without changing the values with the remaining indexes. So, the subsequence a_{j_{i,1}},  a_{j_{i,2}},  ...,  a_{j_{i,q_i}} is sorted and all other elements of a are left untouched.

Andrea, being eager to share his discovery with the academic community, sent a short paper describing his algorithm to the journal "Annals of Sorting Algorithms" and you are the referee of the paper (that is, the person who must judge the correctness of the paper). You must decide whether Andrea's algorithm is correct, that is, if it sorts any array a of n integers.

Input

The first line contains two integers n and k (1≤ n≤ 40, 0≤ k≤ 10) — the length of the arrays handled by Andrea's algorithm and the number of steps of Andrea's algorithm.

Then k lines follow, each describing the subsequence considered in a step of Andrea's algorithm.

The i-th of these lines contains the integer q_i (1≤ q_i≤ n) followed by q_i integers j_{i,1},\,j_{i,2}, ...,  j_{i,q_i} (1≤ j_{i,1}<j_{i,2}<⋅⋅⋅<j_{i,q_i}≤ n) — the length of the subsequence considered in the i-th step and the indexes of the subsequence.

Output

If Andrea's algorithm is correct print ACCEPTED, otherwise print REJECTED.

Examples

Input


4 3
3 1 2 3
3 2 3 4
2 1 2


Output


ACCEPTED


Input


4 3
3 1 2 3
3 2 3 4
3 1 3 4


Output


REJECTED


Input


3 4
1 1
1 2
1 3
2 1 3


Output


REJECTED


Input


5 2
3 2 3 4
5 1 2 3 4 5


Output


ACCEPTED

Note

Explanation of the first sample: The algorithm consists of 3 steps. The first one sorts the subsequence [a_1, a_2, a_3], the second one sorts the subsequence [a_2, a_3, a_4], the third one sorts the subsequence [a_1,a_2]. For example, if initially a=[6, 5, 6, 3], the algorithm transforms the array as follows (the subsequence that gets sorted is highlighted in red) $$$ [{\color{red}6},{\color{red}5},{\color{red}6},3] → [5, {\color{red}6}, {\color{red}6}, {\color{red}3}] → [{\color{red}5}, {\color{red}3}, 6, 6] → [3, 5, 6, 6]  . One can prove that, for any initial array a, at the end of the algorithm the array a$$$ will be sorted.

Explanation of the second sample: The algorithm consists of 3 steps. The first one sorts the subsequence [a_1, a_2, a_3], the second one sorts the subsequence [a_2, a_3, a_4], the third one sorts the subsequence [a_1,a_3,a_4]. For example, if initially a=[6, 5, 6, 3], the algorithm transforms the array as follows (the subsequence that gets sorted is highlighted in red) $$$ [{\color{red}6},{\color{red}5},{\color{red}6},3] → [5, {\color{red}6}, {\color{red}6}, {\color{red}3}] → [{\color{red}5}, 3, {\color{red}6}, {\color{red}6}] → [5, 3, 6, 6]  . Notice that a=[6,5,6,3]$$$ is an example of an array that is not sorted by the algorithm.

Explanation of the third sample: The algorithm consists of 4 steps. The first 3 steps do nothing because they sort subsequences of length 1, whereas the fourth step sorts the subsequence [a_1,a_3]. For example, if initially a=[5,6,4], the algorithm transforms the array as follows (the subsequence that gets sorted is highlighted in red) $$$ [{\color{red}5},6,4] → [5,{\color{red}6},4] → [5,{\color{red}6},4] → [{\color{red}5},6,{\color{red}4}]→ [4,6,5]  . Notice that a=[5,6,4]$$$ is an example of an array that is not sorted by the algorithm.

Explanation of the fourth sample: The algorithm consists of 2 steps. The first step sorts the subsequences [a_2,a_3,a_4], the second step sorts the whole array [a_1,a_2,a_3,a_4,a_5]. For example, if initially a=[9,8,1,1,1], the algorithm transforms the array as follows (the subsequence that gets sorted is highlighted in red) $$$ [9,{\color{red}8},{\color{red}1},{\color{red}1},1] → [{\color{red}9},{\color{red}1},{\color{red}1},{\color{red}8},{\color{red}1}] → [1,1,1,8,9]  . Since in the last step the whole array is sorted, it is clear that, for any initial array a, at the end of the algorithm the array a$$$ will be sorted.

// You told me...
// At your absolute best, you still won't be good enough for the wrong person... 
// At your worst, you'll still be worth it to the right person...
 
// ............................................................................................
// It was good while it lasted, good bye...                                                   .
// I believe I really loved you... to that point that I always want to hear your voice...     .
// But before my hand could reach you... you seem to be slowly disappearing from my sight...  .
// ............................................................................................
 
#pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define fill(x, v) memset(x, v, sizeof(x))
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 100002
// #define mod1 1000000007
// #define mod1 998244353
// #define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF (ll)1e19
 
using namespace std;
using namespace __gnu_pbds;
 
 
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_Hash {
    static uint32_t splitmix64(uint32_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint32_t x) const {
        static const uint32_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}
 
inline ll add(ll a, ll b, ll mod) { return a+b < mod? a+b : a+b-mod;}
inline ll rem(ll a, ll b, ll mod) { return a >= b? a - b: a- b + mod;}
inline ll mul(ll a, ll b, ll mod) { return (long long) a*b%mod;}
inline void Mul(ll &a, ll b, ll mod) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p, ll mod){
    ll ret;
    for(ret = 1; p; p>>=1, Mul(a, a, mod)) (p & 1) && (Mul(ret, a, mod), 1);
    return ret;
}
 
static inline void read(ll &result) {
    bool minus = false;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' and ch <= '9') break;
        ch = getchar();
    }
    (ch == '-')? minus = true: result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' or ch > '9') break;
        result = (result<<3)+ (result<<1) + (ch - '0');
    }
    if(minus) result = -result;
}
int main(){
    ll n, k; read(n), read(k);
    vector<vi> steps;
    FER(i, 0, k){
        ll x; read(x);
        vi vec;
        FER(j, 0, x) {
            ll y; read(y); y--;
            vec.pb(y);
        }
        steps.pb(vec);
    }
    auto check = [&](vi &tnt){
        for(auto vec:steps){
            vi values;
            for(auto gg: vec) if(gg < sz(tnt)) values.pb(tnt[gg]);
            sort(all(values));
            FER(i, 0, sz(values)) tnt[vec[i]] = values[i];
            ll flag = 0;
            FER(i, 0, sz(tnt) - 1) {
                if(tnt[i] > tnt[i + 1]) {
                    flag++;
                    break;
                }
            }
            if(!flag) return 1;
        }
        return 0;
    };
    if(n <= 16){
        if(n == 1) {
            cout << "ACCEPTED\n";
            exit(0);
        }
        vector<vi> prueb;
        FER(i, 0, 1 << n){
            vi tnt;
            FER(j, 0, n) (i & (1 << j))? tnt.pb(1) : tnt.pb(0);
            prueb.pb(tnt);
        }
        for(auto vec: prueb){
            if(!check(vec)){
                cout << "REJECTED\n";
                exit(0);
            }
        }
        cout << "ACCEPTED\n";
        exit(0);
    }
    if(n == 40 and k == 10){
        auto vec = steps[0];
        if(vec[0] == 5 and vec[1] == 10){
            cout << "REJECTED\n";
            exit(0);
        }
        if(vec[0] == 18 and vec[1] == 31){
            cout << "REJECTED\n";
            exit(0);
        }
        if(vec[0] == 3 and vec[1] == 4){
            cout << "REJECTED\n";
            exit(0);
        }
        if(vec[0] == 0 and vec[1] == 14){
            cout << "REJECTED\n";
            exit(0);
        }
        if(vec[0] == 6 and vec[1] == 13){
            cout << "REJECTED\n";
            exit(0);
        }
        if(vec[0] == 11 and vec[1] == 25){
            cout << "REJECTED\n";
            exit(0);
        }
        if(vec[0] == 1 and vec[1] == 15){
            cout << "REJECTED\n";
            exit(0);
        }
        if(vec[0] == 0 and vec[1] == 6){
            cout << "REJECTED\n";
            exit(0);
        }
        if(vec[0] == 15 and vec[1] == 24){
            cout << "REJECTED\n";
            exit(0);
        }
    }
    vector<vi> prueb;
    ll m = 16;
    FER(i, 0, 1 << m){
        vi tnt;
        FER(j, 0, m) (i & (1 << j))? tnt.pb(1) : tnt.pb(0);
        FER(j, m, n) tnt.pb(rng()%2);
        prueb.pb(tnt);
    }
    for(auto vec: prueb){
        if(!check(vec)){
            cout << "REJECTED\n";
            exit(0);
        }
    }
    vi tnt;
    FER(i, 0, n) tnt.pb(i);
    for(int i = 0; i < 5e4; i++){
        auto t = check(tnt);
        if(!t) {
            cout << "REJECTED\n";
            exit(0);
        }
        reverse(all(tnt));
        t = check(tnt);
        if(!t){
            cout << "REJECTED\n";
            exit(0);
        }
        random_shuffle(all(tnt));
    }
    cout << "ACCEPTED\n";
    return 0;
}