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

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

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

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

i.v = f
f.x = m
l.o = i
l.v = f
l.r = k
k.o = i
k.v = f
k.r = m
m.o = i
m.v = f
m.r = k
assert l.o.v.x.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

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