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

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

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

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

h.w = g
h.r = c
h.t = e
g.z = h
e.r = h
l.z = h
c.r = h
i.z = h
assert l.z.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.r: C = None
        self.t: C = None
        self.txt = txt

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

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

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

h.w = g
h.r = c
h.t = e
g.z = h
e.r = h
l.z = h
c.r = h
i.z = h
assert l.z.t.r.txt == "h"