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

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

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

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

l.w = g
a.u = h
j.s = l
h.w = a
g.u = h
e.s = l
assert a.u.w.u.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

l.w = g
a.u = h
j.s = l
h.w = a
g.u = h
e.s = l
assert a.u.w.u.w.u.txt == "h"