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

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

h = A("h")
m = B("m")
j = B("j")
c = A("c")
d = A("d")
i = A("i")
b = B("b")

h.t = m
m.v = j
j.v = m
c.t = b
d.t = j
i.t = b
b.v = m
assert d.t.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

h = A("h")
m = B("m")
j = B("j")
c = A("c")
d = A("d")
i = A("i")
b = B("b")

h.t = m
m.v = j
j.v = m
c.t = b
d.t = j
i.t = b
b.v = m
assert d.t.v.v.v.v.v.txt == "m"