#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

set<ll> num(State &);
set<ll> factor(State &);
set<ll> term(State &);
set<ll> expr(State &);
set<ll> s[6];

set<ll> num(State &begin) {
	int i = *begin - 'A';
	begin++;
	set<ll> res = s[i];
	return res;
}
set<ll> factor(State &begin) {
	if (*begin == '(') {
		begin++;
		set<ll> tmp = expr(begin);
		begin++;
		return tmp;
	} else {
		return num(begin);
	}
}
set<ll> term(State &begin) {
	if (*begin == 'c') {
		begin++;
		set<ll> tmp = factor(begin);
		set<ll> res;
		set_difference(s[5].begin(), s[5].end(), tmp.begin(), tmp.end(), inserter(res, res.end()));
		return res;
	} else {
		return factor(begin);
	}
}

set<ll> expr(State &begin) {
	set<ll> res = term(begin);
	while (1) {
		if (*begin == 'u') {
			begin++;
			set<ll> ans, tmp = term(begin);
			set_union(res.begin(), res.end(), tmp.begin(), tmp.end(), inserter(ans, ans.end()));
			res = ans;
		} else if (*begin == 'i') {
			begin++;
			set<ll> ans, tmp = term(begin);
			set_intersection(res.begin(), res.end(), tmp.begin(), tmp.end(), inserter(ans, ans.end()));
			res = ans;
		} else if (*begin == 'd') {
			begin++;
			set<ll> ans, tmp = term(begin);
			set_difference(res.begin(), res.end(), tmp.begin(), tmp.end(), inserter(ans, ans.end()));
			res = ans;
		} else if (*begin == 's') {
			begin++;
			set<ll> ans, tmp = term(begin);
			set_symmetric_difference(res.begin(), res.end(), tmp.begin(), tmp.end(), inserter(ans, ans.end()));
			res = ans;
		} else {
			break;
		}
	}
	return res;
}

int main() {
	IOS();
	char a;
	int b;
	while (cin >> a >> b) {
		if (a == 'R') {
			string t;
			cin >> t;
			State begin = t.begin();
			set<ll> ans = expr(begin);
			if (ans.size() == 0) {
				dump("NULL");
			} else {
				bool blank = false;
				for (auto it = ans.begin(); it != ans.end(); it++) {
					if (blank) cout << " ";
					cout << *it;
					blank = true;
				}
				cout << endl;
			}
			for (int i = 0; i < 6; i++) {
				s[i].clear();
			}
		} else {
			int i = a - 'A';
			for (int j = 0; j < b; j++) {
				ll x;
				cin >> x;
				s[i].insert(x);
			}
			for (int j = 0; j < 5; j++) {
				for (auto it = s[j].begin(); it != s[j].end(); it++) {
					s[5].insert(*it);
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3100