#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


using S = set<int>;
S U;
map<char, S> m;

string s;
int N;
int c;

S expr();
S factor();
S num();

void debug(string text){
	return;
	cout << text + " " + s << endl;
	for(int i = 0; i < text.size() + 1 + N; i++){
		if(i == text.size() + 1 + c) cout << "*";
		else cout << " ";
	}
	cout << endl;
}

S Union(S s1, S s2){
	for(auto v : s2){
		s1.insert(v);
	}
	return s1;
}

S Intersection(S s1, S s2){
	S ret;
	for(auto v : s2){
		if(s1.count(v)) ret.insert(v);
	}
	return ret;
}

S Diff(S s1, S s2){
	S ret;
	for(auto v : s1){
		if(!s2.count(v)) ret.insert(v);
	}
	return ret;
}

S SymDiff(S s1, S s2){
	S ret;
	for(auto v : s1){
		if(!s2.count(v)) ret.insert(v);
	}
	for(auto v : s2){
		if(!s1.count(v)) ret.insert(v);
	}
	return ret;
}

S Comp(S s1){
	S ret;
	for(auto v : U){
		if(!s1.count(v)) ret.insert(v);
	}
	return ret;
}

S expr(){
	debug("expr");
	S x = factor();
	while(c < N){
		if(s[c] == 'u'){
			c++;
			x = Union(x, factor());
		}
		else if(s[c] == 'i'){
			c++;
			x = Intersection(x, factor());
		}
		else if(s[c] == 'd'){
			c++;
			x = Diff(x, factor());
		}
		else if(s[c] == 's'){
			c++;
			x = SymDiff(x, factor());
		}
		else break;
	}
	return x;
}

S factor(){
	debug("factor");
	bool rev = false;
	if(s[c] == 'c'){
		rev = 1;
		c++;
	}

	if(s[c] == '('){
		c++;
		S ret = expr();
		assert(s[c] == ')');
		c++;
		if(rev) ret = Comp(ret);
		return ret;
	}
	S ret = num();
	if(rev) ret = Comp(ret);
	return ret;
}

S num(){
	debug("num");
	S ret = m[s[c]];
	c++;
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	while(true){
		m.clear();
		U.clear();
		char name;
		int n;
		while(true){
			if(!(cin >> name >> n)) return 0;
			if(name == 'R') break;
			for(int i = 0; i < n; i++){
				int a;
				cin >> a;
				U.insert(a);
				m[name].insert(a);
			}
		}
		//m['U'] = U;
		cin >> s;
		N = s.size();
		c = 0;
		S ans = expr();
		if(ans.size()){
			vector<int> v(ans.begin(), ans.end());
			for(int i = 0; i < v.size(); i++){
				cout << v[i];
				if(i != v.size() - 1) cout << " ";
			}
			cout << endl;
		}
		else{
			cout << "NULL" << endl;
		}
	}
}