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

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

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

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

d.x = m
l.o = k
f.z = k
f.x = m
k.o = j
j.o = l
m.z = k
m.x = f
assert d.x.x.x.z.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.o: B = None
        self.txt = txt

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

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

d.x = m
l.o = k
f.z = k
f.x = m
k.o = j
j.o = l
m.z = k
m.x = f
assert d.x.x.x.z.o.o.txt == "l"