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

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

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

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

f.x = n
g.r = f
c.o = n
n.o = c
l.r = f
e.x = n
assert c.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

f.x = n
g.r = f
c.o = n
n.o = c
l.r = f
e.x = n
assert c.o.o.o.txt == "n"