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

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

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

h = A("h")
g = B("g")
c = C("c")
e = B("e")
i = B("i")

h.y = g
h.z = i
h.r = e
g.o = c
c.s = g
c.w = e
c.x = h
e.o = c
i.o = c
assert c.w.o.x.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: B = None
        self.r: B = None
        self.txt = txt

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

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

h = A("h")
g = B("g")
c = C("c")
e = B("e")
i = B("i")

h.y = g
h.z = i
h.r = e
g.o = c
c.s = g
c.w = e
c.x = h
e.o = c
i.o = c
assert c.w.o.x.r.o.txt == "c"