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

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

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

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

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

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

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

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

h.w = g
h.o = d
h.y = d
g.s = h
d.o = h
assert g.s.w.s.txt == "h"