#include #include using namespace std; using namespace atcoder; int sigma = 26; int op(int x, int y) { return x & y; } int e() { return (1 << sigma) - 1; } int mapping(int f, int x) { return ((x << f) & ((1 << sigma) - 1)) | (x >> (sigma - f)); } int composition(int f, int g) { return (f + g) % sigma; } int id_() { return 0;} int op_ord(int x, int y) { return x + y; } int e_ord() { return 0; } int mapping_ord(int f, int x) { return (f + x) % sigma; } int composition_ord(int f, int g) { return (f + g) % sigma; } int id_ord() { return 0; } int main() { string s, t; cin >> s >> t; int min_st = min(s.size(), t.size()); vector diff_bitset(min_st); for (int i = 0; i < min(s.size(), t.size()); i++) { diff_bitset[i] = 1 << ((s[i] - t[i] + 26) % 26); } lazy_segtree seg_diff_set(diff_bitset); vector ord_s(s.size() + 1); for (int i = 0; i < s.size(); i++) { ord_s[i] = (int)(s[i] - 'a'); } ord_s[s.size()] = -1; vector ord_t(t.size() + 1); for (int i = 0; i < t.size(); i++) { ord_t[i] = (int)(t[i] - 'a'); } ord_t[t.size()] = -1; lazy_segtree seg_s(ord_s); lazy_segtree seg_t(ord_t); int q; cin >> q; while (q--) { int cmd; cin >> cmd; if (cmd == 1) { int l, r, x; cin >> l >> r >> x; seg_diff_set.apply(min(l - 1, min_st), min(r, min_st), x); seg_s.apply(l - 1, r, x); } else if (cmd == 2) { int l, r, x; cin >> l >> r >> x; seg_diff_set.apply(min(l - 1, min_st), min(r, min_st), sigma - x); seg_t.apply(l - 1, r, x); } else { int p; cin >> p; int idx = seg_diff_set.max_right(p - 1, [&](int x) { return x & 1 == 1; }); int s_i = seg_s.get(idx); int t_i = seg_t.get(idx); if (s_i > t_i) { cout << "Greater" << endl; } else if (s_i < t_i) { cout << "Lesser" << endl; } else { cout << "Equals" << endl; } } } }