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

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

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

c = A("c")
l = B("l")
e = C("e")
m = B("m")
d = A("d")
i = A("i")
b = C("b")
f = A("f")

c.p = l
l.r = e
e.z = l
e.v = d
m.r = b
d.p = m
i.p = l
b.z = m
b.v = c
f.p = m
assert d.p.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

c = A("c")
l = B("l")
e = C("e")
m = B("m")
d = A("d")
i = A("i")
b = C("b")
f = A("f")

c.p = l
l.r = e
e.z = l
e.v = d
m.r = b
d.p = m
i.p = l
b.z = m
b.v = c
f.p = m
assert d.p.r.z.txt == "m"