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

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

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

f = A("f")
k = B("k")
d = C("d")
g = C("g")

f.u = k
k.o = g
d.o = f
g.o = f
assert k.o.o.u.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: C = None
        self.txt = txt

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

f = A("f")
k = B("k")
d = C("d")
g = C("g")

f.u = k
k.o = g
d.o = f
g.o = f
assert k.o.o.u.o.txt == "g"