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

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

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

f = A("f")
b = B("b")
g = C("g")
a = B("a")
d = C("d")
k = A("k")

f.z = g
b.t = g
g.w = d
g.y = d
g.s = b
a.t = g
d.w = g
d.y = g
d.s = a
k.z = d
assert k.z.w.s.t.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

f = A("f")
b = B("b")
g = C("g")
a = B("a")
d = C("d")
k = A("k")

f.z = g
b.t = g
g.w = d
g.y = d
g.s = b
a.t = g
d.w = g
d.y = g
d.s = a
k.z = d
assert k.z.w.s.t.w.s.txt == "a"