#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
#include <cctype>
#include <cassert>
using namespace std;
typedef string::const_iterator State;
const int MOD=1000000007;
const int INF=1000000000;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
ll p=0;
bool zerodiv=false;
string t;
set<int> A;
set<int> B;
set<int> C;
set<int> D;
set<int> E;
set<int> U;

// 和集合の計算
template<class T>  set<T> Union(const set<T>& rsettA, const set<T>& rsettB) {
    set<T> settUnion(rsettA);
    for (typename set<T>::iterator itt = rsettB.begin(); itt != rsettB.end(); itt++) {
        settUnion.insert(*itt);
    }
    return settUnion;
}
// 積集合の計算
template<class T>  set<T> Product(const set<T>& rsettA,const set<T>& rsettB) {
    set<T> settProduct;
    for (typename set<T>::iterator itt = rsettB.begin(); itt != rsettB.end(); itt++) {
        if (rsettA.find(*itt) != rsettA.end()) {
            settProduct.insert(*itt);
        }
    }
    return settProduct;
}

// 補集合の計算
template<class T>  set<T> Complement(const set<T>& rsettA,const set<T>& rsettB) {
    set<T> settComplement(rsettA);
    for (typename set<T>::iterator itt = rsettB.begin(); itt != rsettB.end(); itt++) {
        settComplement.erase(*itt);
    }
    return settComplement;
}

//symmetric differenceの計算
template<class T>  set<T> Symmetric(const set<T>& rsettA,const set<T>& rsettB) {
  return Union(Complement(rsettA,rsettB),Complement(rsettB,rsettA));
}

class Parser{
public:
 
  set<int> number(State &begin)
  {
    set<int> ret;
    // while(*begin==')' || *begin=='(') begin++;
    assert(isupper(*begin));
    if(*begin=='A')
      {
	ret=A;
      }
    else if(*begin=='B')
      {	  
	ret=B;
      }
    else if(*begin=='C')
      {
	ret=C;
      }
    else if(*begin=='D')
      {
	ret=D;
      }
    else if(*begin=='E')
      {
	ret=E;
      }
    ++begin;
    return ret;
  }
 
  set<int> expression(State &begin)
  {
    set<int> ret=term(begin);
    for(;;)
      {
	if(*begin=='u')
	  {
	    begin++;
	    ret=Union(ret,term(begin));
	  }
	else if(*begin=='i')
	  {
	    begin++;
	    ret=Product(ret,term(begin));
	  }
	else if(*begin=='d')
	  {
	    begin++;
	    ret=Complement(ret,term(begin));
	  }
	else if(*begin=='s')
	  {
	    begin++;
	    ret=Symmetric(ret,term(begin));
	  }
	else
	  {
	    break;
	  }
      }
    return ret;
  }
 
  set<int> term(State &begin)
  {
    set<int> ret;
    if(*begin=='c')
      {
	begin++;
	ret=Complement(U,term(begin));
      }
    else
      {
	ret=factor(begin);
      }
    return ret;
  }
 
  set<int> factor(State &begin)
  {
    set<int> ret;
    if(*begin=='(')
      {
	begin++;
        ret=expression(begin);
	assert(*begin == ')');
	begin++;
	return ret;
      }
    else
      {
	ret=number(begin);
      }
    return ret;
  }
};
 
 
int main(int argc,char const* argv[])
{
  char setname;
  int setnum;
  string t;
  while(cin)
    {
      A.clear();
      B.clear();
      C.clear();
      D.clear();
      E.clear();
      while(cin >> setname >> setnum)
	{
	  if(setname=='R') break;
	  for(int i=0;i<setnum;i++)
	    {
	      int inum;
	      cin >> inum;
	      if(setname=='A')
		{
		  A.insert(inum);
		}
	      if(setname=='B')
		{
		  B.insert(inum);
		}
	      if(setname=='C')
		{
		  C.insert(inum);
		}
	      if(setname=='D')
		{
		  D.insert(inum);
		}
	      if(setname=='E')
		{
		  E.insert(inum);
		}
	    }
	}
      if(!cin) break;
      U=Union(A,B);
      U=Union(U,C);
      U=Union(U,D);
      U=Union(U,E);
      cin >> t;
      Parser ps;
      State begin=t.begin();
      set<int> ans=ps.expression(begin);
      if(int(ans.size())==0)
	{
	  cout << "NULL" << endl;
	}
      else
	{
	  for(auto it=ans.begin();it!=ans.end();it++)
	    {
	      if (next(it) == ans.end()) 
		{
		  cout << *it << endl;;
		}
	      else
		{
		  cout << *it << ' ';
		}
	    }
	}
      //cout << "END" << endl;
    }
  return 0;
}



Measured memory_bytes: 3208