This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0355"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <chrono>
static const int MOD1 = 1000000861, MOD2 = 1000000933;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using namespace std;
#include "../string/rolling_hash.cpp"
vector<rolling_hash<MOD1>> hashs1;
vector<rolling_hash<MOD2>> hashs2;
#include "../datastructure/lazysegtree.cpp"
struct Monoid{
using T = array<ll, 3>;
using L = char;
static T f(T a, T b) {
return {(a[0]*rolling_hash<MOD1>::p()[b[2]]+b[0])%MOD1, (a[1]*rolling_hash<MOD2>::p()[b[2]]+b[1])%MOD2, a[2]+b[2]};
}
static T g(T a, L b) {
if(b == l()) return a;
else {
return {hashs1[b-'a'].get(0, a[2]), hashs2[b-'a'].get(0, a[2]), a[2]};
}
}
static L h(L a, L b) {
if(b == l()) return a; else return b;
}
static T e() { return {0, 0, 0}; }
static L l() { return 0; }
};
int main() {
int n;
string s;
cin >> n >> s;
for (int i = 'a'; i <= 'z'; ++i) {
hashs1.emplace_back(string(n, i));
hashs2.emplace_back(string(n, i));
}
LazySegmentTree<Monoid> seg(n);
for (int i = 0; i < n; ++i) {
seg.set(i, {s[i], s[i], 1});
}
seg.build();
int q;
cin >> q;
for (int i = 0; i < q; ++i) {
string qq;
cin >> qq;
if(qq == "comp"){
int a, b, c, d;
cin >> a >> b >> c >> d;
a--; c--;
int ok = 0, ng = min(b-a+1, d-c+1);
while(ng-ok > 1){
int mid = (ok+ng)/2;
if(seg.query(a, a+mid) == seg.query(c, c+mid)) ok = mid;
else ng = mid;
}
if(a+ok == b && c+ok == d){
puts("e");
}else if(a+ok == b){
puts("s");
}else if(c+ok == d){
puts("t");
}else if(seg.query(a+ok, a+ng) < seg.query(c+ok, c+ng)){
puts("s");
}else {
puts("t");
}
}else {
int a, b; char c;
cin >> a >> b >> c;
a--;
seg.update(a, b, c);
}
}
return 0;
}
#line 1 "test/aoj0355.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0355"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <chrono>
static const int MOD1 = 1000000861, MOD2 = 1000000933;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using namespace std;
#line 2 "util/xorshift.cpp"
class xor_shift {
uint32_t x, y, z, w;
public:
xor_shift() : x(static_cast<uint32_t>((chrono::system_clock::now().time_since_epoch().count())&((1LL << 32)-1))),
y(1068246329), z(321908594), w(1234567890) {};
uint32_t urand(){
uint32_t t;
t = x ^ (x << 11);
x = y; y = z; z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
return w;
};
int rand(int n){
if(n < 0) return -rand(-n);
uint32_t t = numeric_limits<uint32_t>::max()/(n+1)*(n+1);
uint32_t e = urand();
while(e >= t) e = urand();
return static_cast<int>(e%(n+1));
}
int rand(int a, int b){
if(a > b) swap(a, b);
return a+rand(b-a);
}
};
#line 2 "string/rolling_hash.cpp"
xor_shift rd;
template<int M>
struct rolling_hash {
static ll &B() {
static ll B_ = rd.rand(2, M-1);
return B_;
}
static vector<ll> &p() {
static vector<ll> p_{1, B()};
return p_;
}
vector<ll> hash;
explicit rolling_hash(const string &s) {
if(p().size() <= s.size()){
int l = p().size();
p().resize(s.size()+1);
for (int i = l; i < p().size(); ++i) {
p()[i] = (p()[i-1]*p()[1])%M;
}
}
hash.resize(s.size()+1, 0);
for (int i = 0; i < s.size(); ++i) {
hash[i+1] = (hash[i]*B() + s[i]) % M;
}
};
ll get(int l, int r){
ll res = hash[r]+M-hash[l]*p()[r-l]%M;
return res >= M ? res-M : res;
}
};
#line 20 "test/aoj0355.test.cpp"
vector<rolling_hash<MOD1>> hashs1;
vector<rolling_hash<MOD2>> hashs2;
#line 1 "datastructure/lazysegtree.cpp"
template <class M>
struct LazySegmentTree{
using T = typename M::T;
using L = typename M::L;
int sz, n, height{};
vector<T> seg; vector<L> lazy;
explicit LazySegmentTree(int n) : n(n) {
sz = 1; while(sz < n) sz <<= 1, height++;
seg.assign(2*sz, M::e());
lazy.assign(2*sz, M::l());
}
void set(int k, const T &x){ seg[k + sz] = x; }
void build(){
for (int i = sz-1; i > 0; --i) seg[i] = M::f(seg[i<<1], seg[(i<<1)|1]);
}
T reflect(int k){ return lazy[k] == M::l() ? seg[k] : M::g(seg[k], lazy[k]); }
void eval(int k){
if(lazy[k] == M::l()) return;
if(k < sz){
lazy[(k<<1)|0] = M::h(lazy[(k<<1)|0], lazy[k]);
lazy[(k<<1)|1] = M::h(lazy[(k<<1)|1], lazy[k]);
}
seg[k] = reflect(k);
lazy[k] = M::l();
}
void thrust(int k){ for (int i = height; i; --i) eval(k>>i); }
void recalc(int k) { while(k >>= 1) seg[k] = M::f(reflect((k<<1)|0), reflect((k<<1)|1));}
void update(int a, const T &x){
thrust(a += sz);
seg[a] = x;
recalc(a);
}
void update(int a, int b, const L &x){
thrust(a += sz); thrust(b += sz-1);
for (int l = a, r = b+1;l < r; l >>=1, r >>= 1) {
if(l&1) lazy[l] = M::h(lazy[l], x), l++;
if(r&1) --r, lazy[r] = M::h(lazy[r], x);
}
recalc(a);
recalc(b);
}
T query(int a, int b){ // [l, r)
thrust(a += sz);
thrust(b += sz-1);
T ll = M::e(), rr = M::e();
for(int l = a, r = b+1; l < r; l >>=1, r>>=1) {
if (l & 1) ll = M::f(ll, reflect(l++));
if (r & 1) rr = M::f(reflect(--r), rr);
}
return M::f(ll, rr);
}
template<class F>
int search_right(int l, F cond){
if(l == n) return n;
thrust(l += sz);
T val = M::e();
do {
while(!(l&1)) l >>= 1;
if(!cond(M::f(val, seg[l]))){
while(l < sz) {
eval(l); l <<= 1;
if (cond(M::f(val, reflect(l)))){
val = M::f(val, reflect(l++));
}
}
return l - sz;
}
val = M::f(val, reflect(l++));
} while((l & -l) != l);
return n;
}
template<class F>
int search_left(int r, F cond){
if(r <= 0) return 0;
thrust((r += sz)-1);
T val = M::e();
do {
r--;
while(r > 1 && r&1) r >>= 1;
if(!cond(M::f(reflect(r), val))){
while(r < sz) {
eval(r);
r = ((r << 1)|1);
if (cond(M::f(reflect(r), val))){
val = M::f(reflect(r--), val);
}
}
return r + 1 - sz;
}
val = M::f(reflect(r), val);
} while((r & -r) != r);
return 0;
}
};
/*
struct Monoid{
using T = array<mint, 2>;
using L = array<mint, 2>;
static T f(T a, T b) { return {a[0]+b[0], a[1]+b[1]}; }
static T g(T a, L b) {
return {a[0] * b[0] + a[1] * b[1], a[1]};
}
static L h(L a, L b) {
return {a[0]*b[0], a[1]*b[0]+b[1]};
}
static T e() { return {0, 0}; }
static L l() { return {1, 0}; }
};
*/
#line 25 "test/aoj0355.test.cpp"
struct Monoid{
using T = array<ll, 3>;
using L = char;
static T f(T a, T b) {
return {(a[0]*rolling_hash<MOD1>::p()[b[2]]+b[0])%MOD1, (a[1]*rolling_hash<MOD2>::p()[b[2]]+b[1])%MOD2, a[2]+b[2]};
}
static T g(T a, L b) {
if(b == l()) return a;
else {
return {hashs1[b-'a'].get(0, a[2]), hashs2[b-'a'].get(0, a[2]), a[2]};
}
}
static L h(L a, L b) {
if(b == l()) return a; else return b;
}
static T e() { return {0, 0, 0}; }
static L l() { return 0; }
};
int main() {
int n;
string s;
cin >> n >> s;
for (int i = 'a'; i <= 'z'; ++i) {
hashs1.emplace_back(string(n, i));
hashs2.emplace_back(string(n, i));
}
LazySegmentTree<Monoid> seg(n);
for (int i = 0; i < n; ++i) {
seg.set(i, {s[i], s[i], 1});
}
seg.build();
int q;
cin >> q;
for (int i = 0; i < q; ++i) {
string qq;
cin >> qq;
if(qq == "comp"){
int a, b, c, d;
cin >> a >> b >> c >> d;
a--; c--;
int ok = 0, ng = min(b-a+1, d-c+1);
while(ng-ok > 1){
int mid = (ok+ng)/2;
if(seg.query(a, a+mid) == seg.query(c, c+mid)) ok = mid;
else ng = mid;
}
if(a+ok == b && c+ok == d){
puts("e");
}else if(a+ok == b){
puts("s");
}else if(c+ok == d){
puts("t");
}else if(seg.query(a+ok, a+ng) < seg.query(c+ok, c+ng)){
puts("s");
}else {
puts("t");
}
}else {
int a, b; char c;
cin >> a >> b >> c;
a--;
seg.update(a, b, c);
}
}
return 0;
}