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

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

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

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

h.w = l
i.t = e
i.p = e
a.u = h
a.r = e
g.t = e
g.p = a
e.u = h
e.r = a
l.w = h
assert l.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

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

h.w = l
i.t = e
i.p = e
a.u = h
a.r = e
g.t = e
g.p = a
e.u = h
e.r = a
l.w = h
assert l.w.w.w.w.w.w.txt == "l"