#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
typedef string::const_iterator State;

map<char, set<int>> mp;

set<int> ev_expr(State &begin);
set<int> ev_term(State &begin);
set<int> ev_setorparen(State &begin);
set<int> ev_set(State &begin);
char ev_op(State &begin);

class ParseError
{
};

void consume(State &begin, char expected)
{

    if (*begin == expected)
    {
        begin++;
    }
    else
    {
        cerr << "Expected:" << expected << " but got '" << *begin << "'" << endl;
        cerr << "Rest string is '";
        while (*begin)
        {
            cerr << *begin++;
        }
        cerr << "'" << endl;
        throw ParseError();
    }
}

/*
AiB
<expr>:=<term><op><expr>|<term>
<term>:=c<setorp>|<setop>
<setorparen>::=<set>|(<expr>)
<op>:=u|i|d|c
<set>:=A|B|C|D
*/
set<int> ev_expr(State &begin)
{
    set<int> ret;

    auto a = ev_term(begin);
    ret = a;
    while (*begin == 'u' || *begin == 'i' || *begin == 'd' || *begin == 's')
    {

        ret.clear();
        char op = ev_op(begin);
        auto b = ev_term(begin);
        //cerr << "op:" << *begin << endl;
        if (op == 'i')
        {
            set_intersection(ALL(a), ALL(b), inserter(ret, ret.end()));
        }
        else if (op == 'u')
        {
            set_union(ALL(a), ALL(b), inserter(ret, ret.end()));
        }
        else if (op == 'd')
        {
            set_difference(ALL(a), ALL(b), inserter(ret, ret.end()));
        }
        else if (op == 's')
        {

            set_symmetric_difference(ALL(a), ALL(b), inserter(ret, ret.end()));
        }
        a = ret;
    }
    return ret;
}

set<int> ev_term(State &begin)
{
    set<int> ret;
    if (*begin == 'c')
    {
        auto u = mp['U'];
        begin++;
        auto target = ev_term(begin);
        set_difference(ALL(u), ALL(target), inserter(ret, ret.end()));
        return ret;
    }
    else
    {
        ret = ev_setorparen(begin);
        return ret;
    }
}

char ev_op(State &begin)
{
    char ret = *begin;
    begin++;
    return ret;
}

set<int> ev_setorparen(State &begin)
{
    if (*begin == '(')
    {
        consume(begin, '(');
        auto ret = ev_expr(begin);
        consume(begin, ')');
        return ret;
    }
    else
    {
        auto ret = ev_set(begin);
        return ret;
    }
}

set<int> ev_set(State &begin)
{

    auto ret = mp[*begin];
    begin++;
    return ret;
}

int main()
{
    while (true)
    {
        mp.clear();
        char name;
        int size;
        bool f = false;
        while (cin >> name >> size)
        {
            f = true;
            if (name == 'R')
                break;
            rep(j, size)
            {
                int t;
                cin >> t;
                //    cerr << name << ":" << t << endl;
                mp[name].insert(t);
                mp['U'].insert(t);
            }
        }
        if (f == false)
            break;
        string s;
        cin >> s;
        // cerr << "eval:" << s << endl;
        State begin = s.begin();
        auto ret = ev_expr(begin);
        if (ret.size() == 0)
        {
            cout << "NULL" << endl;
        }
        else
        {
            int count = 0;
            for (auto i : ret)
            {
                cout << i << (count == ret.size() - 1 ? "" : " ");
                count++;
            }

            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3204