#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pair;
#define pb push_back
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n;
cin >> n;
vector<ll> a(n + 1), b(n + 1);
for (ll i = 1; i <= n; i++) cin >> a[i];
for (ll i = 1; i <= n; i++) cin >> b[i];
vector<Pair> ans;
vector<char> ch;
ans.pb({1, n});
ch.pb('I');
sort(a.begin() + 1, a.end());
for (ll i = 1; i <= n; i++) {
if (a[i] == b[i]) continue;
ll j = i + 1;
while (a[j] != b[i]) j++;
sort(a.begin() + i, a.begin() + j + 1);
ans.pb({i, j});
if (b[i] > a[i]) {
ch.pb('D');
reverse(a.begin() + i, a.begin() + j + 1);
}
else ch.pb('I');
}
cout << ans.size() << "\n";
for (ll i = 0; i < ans.size(); i++) {
cout << ans[i].first << " " << ans[i].second << " " << ch[i] << "\n";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnR5cGVkZWYgbG9uZyBsb25nIGxsOwp0eXBlZGVmIHBhaXI8bGwsIGxsPiBQYWlyOwojZGVmaW5lIHBiIHB1c2hfYmFjawoKaW50IG1haW4oKSB7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOyAKICAgIGNpbi50aWUoMCk7CgogICAgbGwgbjsKICAgIGNpbiA+PiBuOwogICAgdmVjdG9yPGxsPiBhKG4gKyAxKSwgYihuICsgMSk7CgogICAgZm9yIChsbCBpID0gMTsgaSA8PSBuOyBpKyspIGNpbiA+PiBhW2ldOwogICAgZm9yIChsbCBpID0gMTsgaSA8PSBuOyBpKyspIGNpbiA+PiBiW2ldOwoKICAgIHZlY3RvcjxQYWlyPiBhbnM7CiAgICB2ZWN0b3I8Y2hhcj4gY2g7CiAgICBhbnMucGIoezEsIG59KTsKICAgIGNoLnBiKCdJJyk7Cglzb3J0KGEuYmVnaW4oKSArIDEsIGEuZW5kKCkpOwogICAgZm9yIChsbCBpID0gMTsgaSA8PSBuOyBpKyspIHsKICAgICAgICBpZiAoYVtpXSA9PSBiW2ldKSBjb250aW51ZTsgICAgICAgIAogICAgICAgIGxsIGogPSBpICsgMTsKICAgICAgICB3aGlsZSAoYVtqXSAhPSBiW2ldKSBqKys7CiAgICAgICAgc29ydChhLmJlZ2luKCkgKyBpLCBhLmJlZ2luKCkgKyBqICsgMSk7CiAgICAgICAgYW5zLnBiKHtpLCBqfSk7CgogICAgICAgIGlmIChiW2ldID4gYVtpXSkgewogICAgICAgICAgICBjaC5wYignRCcpOwogICAgICAgICAgICByZXZlcnNlKGEuYmVnaW4oKSArIGksIGEuYmVnaW4oKSArIGogKyAxKTsKICAgICAgICB9CiAgICAgICAgZWxzZSBjaC5wYignSScpOwogICAgfQoKICAgIGNvdXQgPDwgYW5zLnNpemUoKSA8PCAiXG4iOwogICAgZm9yIChsbCBpID0gMDsgaSA8IGFucy5zaXplKCk7IGkrKykgewogICAgICAgIGNvdXQgPDwgYW5zW2ldLmZpcnN0IDw8ICIgIiA8PCBhbnNbaV0uc2Vjb25kIDw8ICIgIiA8PCBjaFtpXSA8PCAiXG4iOwogICAgfQoKICAgIHJldHVybiAwOwp9Cg==