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

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

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

j = A("j")
k = B("k")
m = C("m")
f = C("f")
l = C("l")
i = B("i")

j.x = f
k.s = j
k.v = j
m.o = f
m.r = l
f.o = m
f.r = m
l.o = m
l.r = f
i.s = j
i.v = j
assert k.s.x.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.s: A = None
        self.v: A = None
        self.txt = txt

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

j = A("j")
k = B("k")
m = C("m")
f = C("f")
l = C("l")
i = B("i")

j.x = f
k.s = j
k.v = j
m.o = f
m.r = l
f.o = m
f.r = m
l.o = m
l.r = f
i.s = j
i.v = j
assert k.s.x.o.o.o.txt == "m"