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

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

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

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

b.u = a
b.w = h
f.u = e
e.o = h
a.u = l
h.u = a
h.w = b
i.u = f
i.w = b
l.o = b
assert h.u.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: A = None
        self.txt = txt

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

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

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

b.u = a
b.w = h
f.u = e
e.o = h
a.u = l
h.u = a
h.w = b
i.u = f
i.w = b
l.o = b
assert h.u.u.o.txt == "b"