class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

e = A("e")
n = B("n")
m = A("m")
h = A("h")

e.r = h
e.t = n
n.o = h
m.r = h
m.t = n
h.r = e
h.t = n
assert n.o.t.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

e = A("e")
n = B("n")
m = A("m")
h = A("h")

e.r = h
e.t = n
n.o = h
m.r = h
m.t = n
h.r = e
h.t = n
assert n.o.t.o.r.txt == "e"