from atcoder.fenwicktree import FenwickTree from atcoder.lazysegtree import LazySegTree sigma = 26 emptyset = -1 wildcard = 9999 def op(x, y): if x == emptyset or y == emptyset: return emptyset if x == wildcard: return y if y == wildcard: return x if x == y: return x else: return emptyset e = wildcard def mapping(f, x): if x == emptyset or x == wildcard: return x return (x + f) % sigma def composition(f, g): return (f + g) % sigma id_ = 0 S = input() T = input() diff = [] for s, t in zip(S, T): diff.append((ord(s) - ord(t)) % sigma) seg = LazySegTree(op, e, mapping, composition, id_, diff) s_imos = FenwickTree(len(S) + 1) t_imos = FenwickTree(len(T) + 1) Q = int(input()) for _ in range(Q): cmd, *query = [int(s) for s in input().split()] if cmd == 1: l, r, x = query seg.apply(min(l - 1, len(S), len(T)), min(r, len(S), len(T)), x) s_imos.add(l - 1, x) s_imos.add(r, -x) elif cmd == 2: l, r, x = query seg.apply(min(l - 1, len(S), len(T)), min(r, len(S), len(T)), -x % sigma) t_imos.add(l - 1, x) t_imos.add(r, -x) else: p = query[0] idx = seg.max_right(p - 1, lambda x: x == 0 or x == wildcard) if idx < min(len(S), len(T)): s = (s_imos.sum(0, idx + 1) + ord(S[idx]) - ord("a")) % sigma t = (t_imos.sum(0, idx + 1) + ord(T[idx]) - ord("a")) % sigma if s > t: print("Greater") elif s < t: print("Lesser") else: if len(S) > len(T): print("Greater") elif len(S) < len(T): print("Lesser") else: print("Equals")