#include<iostream>
#include<set>
#include<map>
#include<vector>
#include<string>
#include<sstream>

#define MAX 128
#define FOR(i,o) for(__typeof((o).begin()) i=(o).begin();i!=(o).end();++i)

using namespace std;

class Set{
public:
  set<int> V;
  Set Union(const Set &t)const{
    Set ret;
    FOR(its,V){ret.V.insert(*its);}
    FOR(its,t.V){ret.V.insert(*its);}
    return ret;
  }
  Set Intersection(const Set &t)const{
    Set ret;
    FOR(its,V){if(t.V.find(*its)!=t.V.end())ret.V.insert(*its);}
    return ret;
  }
  Set Difference(const Set &t)const{
    Set ret;
    FOR(its,V){if(t.V.find(*its)==t.V.end())ret.V.insert(*its);}
    return ret;
  }
  Set Symmetric(const Set &t)const{
    Set ret;
    FOR(its,V){if(t.V.find(*its)==t.V.end())ret.V.insert(*its);}
    FOR(its,t.V){if(V.find(*its)==V.end())ret.V.insert(*its);}
    return ret;
  }
  string toString()const{
    ostringstream oss;
    if(V.size() == 0)oss<<"NULL";
    FOR(its,V){
      if(its!=V.begin())oss<<' ';
      oss<<*its;
    }
    return oss.str();
  }
  Set Complement()const;
};

typedef pair<Set,int> parsed;

Set U; // universal Set
Set emptySet;
map<char,Set> defaultSets;

Set Set::Complement()const{
  Set ret;
  FOR(its,U.V){if(V.find(*its)==V.end())ret.V.insert(*its);}
  return ret;
}

parsed Term(int pos, const string &expr);
parsed Expr(int pos, const string &expr);

parsed Expr(int pos, const string &expr){
  parsed ret;
  //  cout << "EXPRESSION : " << pos << ' ' << expr[pos] << endl;
  ret = Term( pos, expr );
  if(ret.second>=expr.length())return ret;
  while( expr[ ret.second ] == 'u' ||
	 expr[ ret.second ] == 'i' ||
	 expr[ ret.second ] == 'd' ||
	 expr[ ret.second ] == 's' ){
    parsed operand = Term( ret.second + 1, expr );
    switch( expr[ ret.second ] ){
    case 'u':ret.first = ret.first.Union( operand.first );break;
    case 'i':ret.first = ret.first.Intersection( operand.first );break;
    case 'd':ret.first = ret.first.Difference( operand.first );break;
    case 's':ret.first = ret.first.Symmetric( operand.first );break;
    }
    ret.second = operand.second;
    if( ret.second >= expr.length() ) break;
  }
  return ret;
}

parsed Term(int pos, const string &expr){
  //  cout << "TERM : " << pos << ' ' << expr[pos] << endl;
  if( expr[pos] == '(' ){
    parsed ret = Expr( pos + 1, expr );
    ret.second++; // skip ')'
    return ret;
  }
  if( expr[pos] == 'A' || expr[pos] == 'B' ||
      expr[pos] == 'C' || expr[pos] == 'D' || expr[pos] == 'E' ){
    return parsed( defaultSets[ expr[pos] ], pos+1 );
  }
  if( expr[pos] == 'c' ){
    parsed ret = Term(pos+1,expr);
    ret.first = ret.first.Complement();
    return ret;
  }
}

int main(){
  while(true){

    defaultSets['A'].V.clear();
    defaultSets['B'].V.clear();
    defaultSets['C'].V.clear();
    defaultSets['D'].V.clear();
    defaultSets['E'].V.clear();
    U.V.clear();
    while(true){
      char c;
      int n;
      cin >> c; if(cin.eof())return 0;
      cin >> n;
      if( c == 'R' && n == 0 ) break;
      for(int i = 0; i < n; ++i){
	int d; cin >> d; defaultSets[c].V.insert(d);
	U.V.insert(d);
      }
    }

    string expr;
    cin >> expr;
    parsed init(emptySet, 0);
    parsed result = init;
    result = Expr(0,expr);
    cout << result.first.toString() << endl;
  }
  return 0;
}