class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: C = None
        self.z: 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.z: C = None
        self.o: B = None
        self.txt = txt

k = A("k")
d = B("d")
g = C("g")
l = A("l")
b = A("b")
m = C("m")
n = C("n")

k.v = d
k.z = d
k.x = m
d.x = n
g.z = n
g.o = d
l.v = d
l.z = d
l.x = n
b.v = d
b.z = d
b.x = g
m.z = g
m.o = d
n.z = g
n.o = d
assert k.x.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: C = None
        self.z: 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.z: C = None
        self.o: B = None
        self.txt = txt

k = A("k")
d = B("d")
g = C("g")
l = A("l")
b = A("b")
m = C("m")
n = C("n")

k.v = d
k.z = d
k.x = m
d.x = n
g.z = n
g.o = d
l.v = d
l.z = d
l.x = n
b.v = d
b.z = d
b.x = g
m.z = g
m.o = d
n.z = g
n.o = d
assert k.x.z.z.txt == "n"