#include <cstdio>
#include <iostream>
#include <set>
#include <string>
#include <stack>
using namespace std;

template <class Set>
void print_set(Set& setA)
{
  typename Set::iterator it;
  int n = 0;
  if (setA.empty()) { cout << "NULL" << endl; return; }
  for (it = setA.begin(); it != setA.end(); ++it)
  {
    n++;
    if (n != setA.size()) printf("%d ", *it);
    else printf("%d\n", *it);
  }
}

// ?????????????¨????
template <class Set>
Set union_set(Set& setA, Set& setB)
{
  Set res(setA);
  typename Set::iterator it;
  for (it = setB.begin(); it != setB.end(); ++it)
  {
    res.insert(*it);
  }
  return res;
}

// ?????????????¨????
template <class Set>
Set intersection_set(Set& setA, Set& setB)
{
  Set res;
  typename Set::iterator it;

  for (it = setB.begin(); it != setB.end(); ++it)
  {
    if (setA.find(*it) != setA.end())
    {
      res.insert(*it);
    }
  }
  return res;
}


// ?£???????????¨????
template <class Set>
Set complement(Set& setA, Set& U)
{
  Set res(U);
  typename Set::iterator it;
  for (it = setA.begin(); it != setA.end(); ++it)
  {
    res.erase(*it);
  }
  return res;
}

// A-B
template <class Set>
Set difference(Set& setA, Set& setB)
{
  Set res(setA);
  typename Set::iterator it;
  for (it = setB.begin(); it != setB.end(); ++it)
  {
    res.erase(*it);
  }
  return res;
}

// A . B
template <class Set>
Set symmetric_difference(Set& setA, Set& setB)
{
  Set s1 = difference(setA, setB);
  Set s2 = difference(setB, setA);
  return union_set(s1, s2);
}

string rev_polish_notation(string& exp)
{
  stack<char> stk;
  string rexp;
  string::iterator it;

  for (it = exp.begin(); it != exp.end(); ++it)
  {
    if (*it == '(')
    {
      stk.push(*it);
    }
    else if (*it == ')')
    {
      while (stk.top() != '(')
      {
        char tkn = stk.top();
        rexp = rexp + tkn;
        stk.pop();
      }
      stk.pop();                // top???'('???????????????
    }
    else if ((*it == 'u') || (*it == 'i') || (*it == 'd') || (*it == 's'))
    {
      while ((!stk.empty()) && (stk.top() != '('))
      {
        char tkn = stk.top();
        rexp = rexp + tkn;
        stk.pop();
      }
      stk.push(*it);
    }
    else if (*it == 'c')
    {
      stk.push(*it);
    }
    else if ((*it == 'A') || (*it == 'B') || (*it == 'C') || (*it == 'D') || (*it == 'E'))
    {
      rexp = rexp + (*it);
    }
  }

  while (!stk.empty())
  {
    char tkn = stk.top();
    rexp = rexp + tkn;
    stk.pop();
  }

  return rexp;
}


template <class Set>
Set set_operation(string& exp, Set& A, Set& B, Set& C, Set& D, Set& E, Set& U)
{
  Set S;
  string rexp = rev_polish_notation(exp); // ???????????????????¨????
  stack<Set> stk;

  string::iterator it;
  for (it = rexp.begin(); it != rexp.end(); ++it)
  {
    if (*it == 'A') { stk.push(A); }
    else if (*it == 'B') { stk.push(B); }
    else if (*it == 'C') { stk.push(C); }
    else if (*it == 'D') { stk.push(D); }
    else if (*it == 'E') { stk.push(E); }
    else if (*it == 'c')
    {
      Set s = stk.top();
      stk.pop();
      stk.push(complement(s, U));
    }
    else if ((*it == 'u') || (*it == 'i') || (*it == 'd') || (*it == 's'))
    {
      Set s1 = stk.top();
      stk.pop();
      Set s2 = stk.top();
      stk.pop();
      Set ans;

      switch (*it)
      {
      case 'u': stk.push(union_set(s1, s2)); break;
      case 'i': stk.push(intersection_set(s1, s2)); break;
      case 'd': stk.push(difference(s2, s1)); break; // ????????????????????¨???
      case 's': stk.push(symmetric_difference(s1, s2)); break;
      }
    }
  }
  return stk.top();
}


int main() {
  set<int> A, B, C, D, E, U;
  char name;
  int num;
  int e;
  string exp;

  while (cin >> name >> num)
  {
    switch (name)
    {
    case 'A':
      for (int i=0;i<num;i++) { cin >> e; A.insert(e); U.insert(e); }
      break;
    case 'B':
      for (int i=0;i<num;i++) { cin >> e; B.insert(e); U.insert(e); }
      break;
    case 'C':
      for (int i=0;i<num;i++) { cin >> e; C.insert(e); U.insert(e); }
      break;
    case 'D':
      for (int i=0;i<num;i++) { cin >> e; D.insert(e); U.insert(e); }
      break;
    case 'E':
      for (int i=0;i<num;i++) { cin >> e; E.insert(e); U.insert(e); }
      break;
    case 'R':
      cin >> exp;
      set<int> res = set_operation(exp, A, B, C, D, E, U);
      print_set(res);
      // ??????????????????????¶???????
      A.clear();
      B.clear();
      C.clear();
      D.clear();
      E.clear();
      U.clear();
      break;
    }
    if (cin.eof()) break;
  }

  return 0;
}

Measured memory_bytes: 1260