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

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

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

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

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

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

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

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

k.r = f
k.s = n
k.w = b
f.t = k
b.y = f
b.z = f
n.r = f
n.s = k
n.w = b
assert f.t.w.y.txt == "f"