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

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

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

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

k.s = b
k.w = d
h.v = d
b.r = d
d.r = b
assert h.v.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.w: C = None
        self.txt = txt

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

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

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

k.s = b
k.w = d
h.v = d
b.r = d
d.r = b
assert h.v.r.r.txt == "d"