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

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

h = A("h")
m = B("m")
n = A("n")
c = A("c")
d = A("d")
a = A("a")

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

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

h = A("h")
m = B("m")
n = A("n")
c = A("c")
d = A("d")
a = A("a")

h.t = m
m.v = h
n.t = m
c.t = m
d.t = m
a.t = m
assert m.v.t.v.t.txt == "m"