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

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

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

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

n.o = k
n.s = h
n.u = h
k.x = n
k.z = h
h.r = n
h.v = n
h.w = k
assert h.w.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.s: C = None
        self.u: C = None
        self.txt = txt

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

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

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

n.o = k
n.s = h
n.u = h
k.x = n
k.z = h
h.r = n
h.v = n
h.w = k
assert h.w.z.w.txt == "k"