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

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

h = A("h")
i = B("i")
c = B("c")

h.w = i
i.w = c
c.w = i
assert c.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

h = A("h")
i = B("i")
c = B("c")

h.w = i
i.w = c
c.w = i
assert c.w.w.w.txt == "i"