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

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

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

b = A("b")
n = B("n")
i = C("i")
h = C("h")

b.p = n
b.r = i
b.z = h
n.x = h
n.y = h
n.s = b
i.u = n
i.w = n
i.q = b
h.u = n
h.w = n
h.q = b
assert n.x.w.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.r: C = None
        self.z: C = None
        self.txt = txt

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

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

b = A("b")
n = B("n")
i = C("i")
h = C("h")

b.p = n
b.r = i
b.z = h
n.x = h
n.y = h
n.s = b
i.u = n
i.w = n
i.q = b
h.u = n
h.w = n
h.q = b
assert n.x.w.s.r.txt == "i"