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

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

h = A("h")
n = B("n")
m = A("m")
i = B("i")
j = A("j")

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

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

h = A("h")
n = B("n")
m = A("m")
i = B("i")
j = A("j")

h.x = n
n.o = i
n.t = i
m.x = n
i.o = n
i.t = n
j.x = i
assert m.x.t.t.o.txt == "i"