#include <iostream>
#include <sstream>
#include <set>
#include <fstream>
#include <algorithm>
#include <cctype>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <string>
#include <cmath>
#include <climits>
#include <stack>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <bitset>
#include <cassert>
#include <tuple>
using namespace std;
typedef unsigned long long ll;
typedef long double ld;
//int mod = 998244353;
int MOD = 1e9 + 7;
int main () {
ios_base::sync_with_stdio (false);
cin.tie (NULL);
int t = 1;
//cin >> t;
while (t--) {
int n, q;
cin >> n >> q;
vector<int> p (n + 1), pos (n + 1);
iota (p.begin (), p.end (), 0);
pos = p;
while (q--) {
char c;
cin >> c;
if (c == 'B') {
int x, y;
cin >> x >> y;
int a = pos[x], b = pos[y];
swap (p[a], p[b]);
pos[x] = b;
pos[y] = a;
} else if (c == 'E') {
int a, b;
cin >> a >> b;
int x = p[a], y = p[b];
swap (pos[x], pos[y]);
p[a] = y;
p[b] = x;
} else {
vector<int> a (n + 1), ans (n + 1);
for (int i = 1 ; i <= n ; i++) {
cin >> a[i];
ans[p[i]] = a[i];
}
for (int i = 1 ; i <= n ; i++) cout << ans[i] << ((i!=n) ? " " : "") ;
if (q) cout << '\n';
}
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPGZzdHJlYW0+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxjY3R5cGU+CiNpbmNsdWRlIDxpb21hbmlwPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8cXVldWU+CiNpbmNsdWRlIDxudW1lcmljPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxjbGltaXRzPgojaW5jbHVkZSA8c3RhY2s+CiNpbmNs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ICAgICAgICAgICBwb3NbeV0gPSBhOwogICAgICAgICAgICB9IGVsc2UgaWYgKGMgPT0gJ0UnKSB7CiAgICAgICAgICAgICAgICBpbnQgYSwgYjsKICAgICAgICAgICAgICAgIGNpbiA+PiBhID4+IGI7CiAgICAgICAgICAgICAgICBpbnQgeCA9IHBbYV0sIHkgPSBwW2JdOwogICAgICAgICAgICAgICAgc3dhcCAocG9zW3hdLCBwb3NbeV0pOwogICAgICAgICAgICAgICAgcFthXSA9IHk7CiAgICAgICAgICAgICAgICBwW2JdID0geDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHZlY3RvcjxpbnQ+IGEgKG4gKyAxKSwgYW5zIChuICsgMSk7CiAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMSA7IGkgPD0gbiA7IGkrKykgewogICAgICAgICAgICAgICAgICAgIGNpbiA+PiBhW2ldOwogICAgICAgICAgICAgICAgICAgIGFuc1twW2ldXSA9IGFbaV07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmb3IgKGludCBpID0gMSA7IGkgPD0gbiA7IGkrKykgY291dCA8PCBhbnNbaV0gPDwgKChpIT1uKSA/ICIgIiA6ICIiKSA7CiAgICAgICAgICAgICAgICBpZiAocSkgY291dCA8PCAnXG4nOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIDA7Cn0=