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

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

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

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

b.w = n
b.x = n
n.y = h
n.p = h
h.o = b
h.u = n
assert h.o.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: B = None
        self.txt = txt

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

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

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

b.w = n
b.x = n
n.y = h
n.p = h
h.o = b
h.u = n
assert h.o.w.p.txt == "h"