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

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

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

h = A("h")
k = B("k")
b = C("b")
l = C("l")
d = B("d")

h.s = d
h.w = k
k.z = l
b.t = l
b.r = l
b.p = k
l.t = b
l.r = b
l.p = k
d.z = l
assert h.w.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: B = None
        self.txt = txt

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

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

h = A("h")
k = B("k")
b = C("b")
l = C("l")
d = B("d")

h.s = d
h.w = k
k.z = l
b.t = l
b.r = l
b.p = k
l.t = b
l.r = b
l.p = k
d.z = l
assert h.w.z.t.txt == "b"