#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Node{
public:
    char ope;
    string s;
    Node *left, *right;
    Node(){
        ope = '\0';
        left = right = NULL;
    }
    ~Node(){
        delete left;
        delete right;
    }
};

// 数式の構文木を作成する
class syntacticAnalysis
{
    vector<int> binaryPriority;       // 二項演算子の優先順位（数値が小さいほど優先順位が高い。-1ならば二項演算子ではない）
    vector<bool> binaryAssociativity; // 二項演算子の結合規則（trueならば左から右に結合）
    vector<bool> isUnaryOpe;          // 単項演算子
    stack<pair<Node*, bool> > stk;
    void deleteAllNodes()
    {
        while(!stk.empty()){
            delete stk.top().first;
            stk.pop();
        }
    }
    bool calc(int maxPriority)
    {
        if(!stk.top().second)
            return false;
        pair<Node*, bool> right = stk.top();
        stk.pop();
        while(stk.top().first != NULL){
            pair<Node*, bool> ope = stk.top();
            if(ope.second)
                break;
            stk.pop();
            if(binaryPriority[ope.first->ope] != -1 && stk.top().second){
                if(binaryPriority[ope.first->ope] > maxPriority ||
                        binaryPriority[ope.first->ope] == maxPriority && !binaryAssociativity[ope.first->ope]){
                    stk.push(ope);
                    break;
                }
                ope.first->right = right.first;
                ope.first->left = stk.top().first;
                ope.second = true;
                right = ope;
                stk.pop();
            }else if(isUnaryOpe[ope.first->ope]){
                ope.first->right = right.first;
                ope.second = true;
                right = ope;
            }else{
                stk.push(ope);
                break;
            }
        }
        bool ret = (stk.top().first == NULL);
        stk.push(right);
        return ret;
    }
public:
    // binaryOpe : 二項演算子（優先順位の高い順に並べる。secondは結合規則を表し、trueならば左から右に結合）
    // unaryOpe  : 単項演算子（前置演算子のみ対応）
    syntacticAnalysis(const vector<pair<string, bool> >& binaryOpe, const string& unaryOpe)
    {
        binaryPriority.assign(128, -1);
        binaryAssociativity.resize(128);
        isUnaryOpe.assign(128, false);
        for(unsigned i=0; i<binaryOpe.size(); ++i){
            for(unsigned j=0; j<binaryOpe[i].first.size(); ++j){
                binaryPriority[binaryOpe[i].first[j]] = i;
                binaryAssociativity[binaryOpe[i].first[j]] = binaryOpe[i].second;
            }
        }
        for(unsigned i=0; i<unaryOpe.size(); ++i)
            isUnaryOpe[unaryOpe[i]] = true;
    }
    Node* makeTree(const string& s)
    {
        int n = s.size();
        int i = 0;
        stk.push(make_pair((Node*)NULL, false));
        while(i < n){
            if(s[i] == '('){
                stk.push(make_pair((Node*)NULL, false));
                ++ i;
            }else if(s[i] == ')'){
                if(!calc(INT_MAX) || stk.size() == 2){
                    deleteAllNodes();
                    return NULL;
                }
                pair<Node*, bool> node = stk.top();
                stk.pop();
                stk.pop();
                stk.push(node);
                ++ i;
            }else if(binaryPriority[s[i]] != -1 || isUnaryOpe[s[i]]){
                calc(binaryPriority[s[i]]);
                Node* node = new Node;
                node->ope = s[i];
                stk.push(make_pair(node, false));
                ++ i;
            }else{
                Node* node = new Node;
                while(i < n && s[i] != '(' && s[i] != ')' && binaryPriority[s[i]] == -1 && !isUnaryOpe[s[i]]){
                    node->s += s[i];
                    ++ i;
                }
                stk.push(make_pair(node, true));
            }
        }

        if(!calc(INT_MAX) || stk.size() != 2){
            deleteAllNodes();
            return NULL;
        }else{
            Node* ret = stk.top().first;
            stk.pop();
            stk.pop();
            return ret;
        }
    }
};

/***************************************************************************************************/
// 強連結成分分解
// edges1 : 有向グラフ
// nodes  : 強連結成分
// edges2 : 新たなグラフ(DAG)
/***************************************************************************************************/

void stronglyConnectedComponents(const vector<vector<int> >& edges1, vector<vector<int> >& nodes, vector<vector<int> >& edges2)
{
    const int n = edges1.size();

    class Func{
        vector<int> num, low;
        vector<bool> isStk;
        stack<int> stk;
        int time;
    public:
        Func(int n){
            num.assign(n, 0);
            low.assign(n, 0);
            isStk.assign(n, false);
            time = 0;
        }
        void visit(const vector<vector<int> >& edges, int v, vector<vector<int> >& nodes){
            if(num[v] != 0)
                return;
            num[v] = low[v] = ++ time;
            stk.push(v);
            isStk[v] = true;
            for(unsigned i=0; i<edges[v].size(); ++i){
                int w = edges[v][i];
                visit(edges, w, nodes);
                if(isStk[w])
                    low[v] = min(low[v], low[w]);
            }
            if(low[v] == num[v]){
                nodes.push_back(vector<int>());
                for(;;){
                    int w = stk.top();
                    stk.pop();
                    isStk[w] = false;
                    nodes.back().push_back(w);
                    if(v == w)
                        break;
                }
            }
        }
    }func(n);

    nodes.clear();
    for(int i=0; i<n; ++i)
        func.visit(edges1, i, nodes);
    reverse(nodes.begin(), nodes.end()); // DAGにするために反転させる

    const int m = nodes.size();
    vector<int> index(n); // 元のグラフの各頂点のDAGにおける頂点
    for(int i=0; i<m; ++i){
        for(unsigned j=0; j<nodes[i].size(); ++j)
            index[nodes[i][j]] = i;
    }
    edges2.assign(m, vector<int>());
    vector<vector<bool> > check(m, vector<bool>(m, false));
    for(int i=0; i<n; ++i){
        for(unsigned j=0; j<edges1[i].size(); ++j){
            int v = index[i];
            int w = index[edges1[i][j]];
            if(v != w && !check[v][w]){
                edges2[v].push_back(w);
                check[v][w] = true;
            }
        }
    }
}

/***************************************************************************************************/
// 2-SAT(satisfiability, 充足性)を調べる。
// n  : 変数の個数
// cs : 節のリスト、x_iの肯定を2*i、x_iの否定を2*i+1の値で表現
/***************************************************************************************************/

bool is2sat(int n, const vector<int>& cs)
{
    vector<vector<int> > edges1(2*n);
    for(unsigned i=0; i<cs.size(); i+=2){
        edges1[cs[i]-cs[i]%2*2+1].push_back(cs[i+1]);
        edges1[cs[i+1]-cs[i+1]%2*2+1].push_back(cs[i]);
    }

    vector<vector<int> > nodes, edges2;
    stronglyConnectedComponents(edges1, nodes, edges2);
    for(unsigned i=0; i<nodes.size(); ++i){
        sort(nodes[i].begin(), nodes[i].end());
        for(unsigned j=0; j<nodes[i].size()-1; ++j){
            if(nodes[i][j]%2 == 0 && nodes[i][j+1] == nodes[i][j]+1)
                return false;
        }
    }
    return true;
}

map<string, int> index;

pair<char, pair<int, int> > solve(Node* x)
{
    pair<char, pair<int, int> > ret;
    if(x->ope == '&'){
        ret.first = '&';
        ret.second.first = solve(x->left).second.first;
        ret.second.second = solve(x->right).second.second;
    }else if(x->ope == '|'){
        ret.first = '|';
        ret.second.first = solve(x->left).second.first;
        ret.second.second = solve(x->right).second.second;
    }else if(x->ope == '~'){
        ret = solve(x->right);
        ret.first = '&' + '|' - ret.first;
        ret.second.first ^= 1;
        ret.second.second ^= 1;
    }else{
        if(index.find(x->s) == index.end()){
            int k = index.size();
            index[x->s] = k;
        }
        ret.first = '&';
        ret.second.first = index[x->s] * 2;
        ret.second.second = index[x->s] * 2;
    }

    return ret;
}

int main()
{
    vector<pair<string, bool> > binaryOpe(1, make_pair("|&", true));
    string unaryOpe = "~";
    syntacticAnalysis sa(binaryOpe, unaryOpe);

    int n, m;
    cin >> n >> m;

    vector<int> cs;
    for(int i=0; i<n; ++i){
        string s;
        cin >> s;
        Node* x = sa.makeTree(s.substr(0, s.size()-1));

        pair<char, pair<int, int> > p = solve(x);
        delete x;

        if(p.first == '&'){
            cs.push_back(p.second.first);
            cs.push_back(p.second.first);
            cs.push_back(p.second.second);
            cs.push_back(p.second.second);
        }else{
            cs.push_back(p.second.first);
            cs.push_back(p.second.second);
        }
    }

    if(is2sat(m, cs))
        cout << "accept" << endl;
    else
        cout << "reject" << endl;

    return 0;
}

Measured memory_bytes: 1492