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

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

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

l = A("l")
j = B("j")
n = C("n")
f = B("f")

l.o = n
j.u = f
n.z = l
n.s = l
f.u = j
assert n.s.o.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

l = A("l")
j = B("j")
n = C("n")
f = B("f")

l.o = n
j.u = f
n.z = l
n.s = l
f.u = j
assert n.s.o.s.o.txt == "n"