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

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

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

a = A("a")
j = B("j")
c = C("c")

a.o = j
j.y = c
c.w = j
assert c.w.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

a = A("a")
j = B("j")
c = C("c")

a.o = j
j.y = c
c.w = j
assert c.w.y.w.txt == "j"