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

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

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

f = A("f")
c = B("c")
g = C("g")
i = B("i")

f.s = g
c.z = f
c.q = g
c.o = g
g.p = c
g.w = f
i.z = f
i.q = g
i.o = g
assert f.s.p.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

f = A("f")
c = B("c")
g = C("g")
i = B("i")

f.s = g
c.z = f
c.q = g
c.o = g
g.p = c
g.w = f
i.z = f
i.q = g
i.o = g
assert f.s.p.q.w.txt == "f"