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

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

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

a = A("a")
h = B("h")
d = C("d")

a.y = d
a.t = d
h.u = a
d.w = h
d.x = h
d.v = a
assert h.u.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: C = None
        self.txt = txt

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

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

a = A("a")
h = B("h")
d = C("d")

a.y = d
a.t = d
h.u = a
d.w = h
d.x = h
d.v = a
assert h.u.y.w.txt == "h"