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

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

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

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

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

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

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

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

b.s = k
b.w = k
b.r = h
k.o = b
k.s = b
h.p = b
assert b.r.p.r.txt == "h"