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

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

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

g = A("g")
c = B("c")
f = C("f")
e = C("e")

g.u = c
c.o = g
f.o = e
e.o = f
assert f.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

g = A("g")
c = B("c")
f = C("f")
e = C("e")

g.u = c
c.o = g
f.o = e
e.o = f
assert f.o.o.o.txt == "e"