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

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

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

d = A("d")
b = B("b")
a = C("a")
m = C("m")
f = B("f")
c = A("c")
j = B("j")
n = A("n")

d.v = m
d.q = a
b.p = a
a.o = n
a.r = f
a.z = f
m.o = n
m.r = f
m.z = b
f.p = m
c.v = a
c.q = m
j.p = a
n.v = m
n.q = m
assert n.q.z.p.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.q: C = None
        self.txt = txt

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

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

d = A("d")
b = B("b")
a = C("a")
m = C("m")
f = B("f")
c = A("c")
j = B("j")
n = A("n")

d.v = m
d.q = a
b.p = a
a.o = n
a.r = f
a.z = f
m.o = n
m.r = f
m.z = b
f.p = m
c.v = a
c.q = m
j.p = a
n.v = m
n.q = m
assert n.q.z.p.o.v.txt == "m"