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

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

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

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

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

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

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

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

h.s = n
h.y = i
h.v = i
n.x = d
n.o = h
n.w = h
i.r = d
i.x = h
d.r = i
d.x = h
assert d.r.x.v.txt == "i"