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

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

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

f = A("f")
b = B("b")
n = C("n")
d = C("d")

f.w = b
b.s = f
b.y = n
n.o = f
d.o = f
assert f.w.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

f = A("f")
b = B("b")
n = C("n")
d = C("d")

f.w = b
b.s = f
b.y = n
n.o = f
d.o = f
assert f.w.y.o.txt == "f"