111
#include <bits/stdc++.h>
#define suc cout << "SUCCESS\n";
#define usc cout << "UNSUCCESS\n";
#define int long long
using namespace std;
signed main() {
stack<int> stk[2];
int id[2] = {0, 1};
string s;
while (cin >> s) {
if (s == "PUSH") {
int p, x;
cin >> p >> x;
p = id[p];
suc;
stk[p].push(x);
} else if (s == "POP") {
int p;
cin >> p;
p = id[p];
if (stk[p].size()) {
suc;
stk[p].pop();
} else {
usc;
}
} else if (s == "ADD") {
int x;
cin >> x;
if (stk[0].size() && stk[1].size()) {
suc;
int v = stk[0].top(), w = stk[1].top();
stk[0].pop(), stk[1].pop();
stk[id[x]].push(v + w);
} else {
usc;
}
} else if (s == "SUB") {
int x;
cin >> x;
if (stk[0].size() && stk[1].size()) {
suc;
int v = stk[0].top(), w = stk[1].top();
stk[0].pop(), stk[1].pop();
stk[id[x]].push(abs(v - w));
} else {
usc;
}
} else if (s == "DEL") {
int x;
cin >> x;
x = id[x];
suc;
while (stk[x].size()) {
stk[x].pop();
}
} else if (s == "MOVE") {
int x, y;
cin >> x >> y;
x = id[x], y = id[y];
suc;
if (stk[x].size() > stk[y].size()) {
while (stk[y].size()) {
stk[x].push(stk[y].top());
stk[y].pop();
}
} else {
while (stk[x].size()) {
stk[y].push(stk[x].size());
stk[x].pop();
}
swap(id[0], id[1]);
}
} else if (s == "SWAP") {
suc;
swap(id[0], id[1]);
} else {
suc;
if (stk[id[0]].size()) {
while (stk[id[0]].size()) {
cout << stk[id[0]].top() << ' ';
stk[id[0]].pop();
}
cout << '\n';
} else {
cout << "NONE\n";
}
if (stk[id[1]].size()) {
while (stk[id[1]].size()) {
cout << stk[id[1]].top() << ' ';
stk[id[1]].pop();
}
cout << '\n';
} else {
cout << "NONE\n";
}
break;
}
}
return 0;
}