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

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

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

k = A("k")
c = B("c")
i = C("i")
h = B("h")

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

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

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

k = A("k")
c = B("c")
i = C("i")
h = B("h")

k.p = h
k.w = h
c.r = h
c.w = h
c.s = k
i.z = c
i.t = k
h.r = c
h.w = c
h.s = k
assert i.t.p.r.s.txt == "k"