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

#define rep(i,n)   for(int i=0;i<n;++i)
#define all(c)     c.begin(),c.end()

using namespace std;
typedef set<int> iset;

string src;
int p;

iset U;
map<char, iset> sets;

iset parse_expr(); // proto

bool end() { return p >= (int)src.length(); }
char peek() { return src[p]; }
void succ() { if (!end()) ++p; }

iset set_u(const iset &a, const iset &b)
{
	iset c = a;
	c.insert(all(b));
	return c;
}

iset set_i(const iset &a, const iset &b)
{
	iset c;
	for (iset::const_iterator it = a.begin(); it != a.end(); ++it)
	{
		if (b.find(*it) != b.end()) c.insert(*it);
	}
	return c;
}

iset set_d(const iset &a, const iset &b)
{
	iset c;
	for (iset::const_iterator it = a.begin(); it != a.end(); ++it)
	{
		if (b.find(*it) == b.end()) c.insert(*it);
	}
	return c;
}

iset set_s(const iset &a, const iset &b)
{
	return set_u(set_d(a, b), set_d(b, a));
}

iset set_c(const iset &a)
{
	return set_d(U, a);
}

iset parse_primary()
{
	iset s;

	char c = peek();
	switch (c)
	{
	case 'c':
		succ();
		s = set_c(parse_primary());
		break;
	case '(':
		succ();
		s = parse_expr();
		if (peek() == ')') succ();
		break;
	default:
		succ();
		s = sets[c];
		break;
	}
	return s;
}

bool is_op()
{
	char c = peek();
	return c=='u'||c=='i'||c=='d'||c=='s';
}

iset parse_expr()
{
	iset a = parse_primary();

	while (!end() && is_op())
	{
		char op = peek();
		succ();

		iset b = parse_primary();
		switch (op)
		{
		case 'u':
			a = set_u(a, b);
			break;
		case 'i':
			a = set_i(a, b);
			break;
		case 'd':
			a = set_d(a, b);
			break;
		case 's':
			a = set_s(a, b);
			break;
		}
	}
	return a;
}

iset parse()
{
	p = 0;
	return parse_expr();
}

int main()
{
	while(!cin.eof())
	{
		char name;
		int N, e;

		U.clear();
		sets.clear();
		while(cin >> name >> N, name != 'R')
		{
			rep(i,N)
			{
				cin >> e;
				sets[name].insert(e);
				U.insert(e);
			}
		}

		cin >> src;
		iset s = parse();
		if (s.empty())
		{
			cout << "NULL" << endl;
			continue;
		}

		for (iset::const_iterator it = s.begin(); it != s.end(); ++it)
		{
			if (it != s.begin()) cout << " ";
			cout << *it;
		}
		cout << endl;

		cin.ignore();
		cin.peek();
	}
	return 0;
}