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

f = A("f")
n = B("n")
m = C("m")
i = B("i")
c = C("c")
e = A("e")
d = B("d")
b = A("b")
h = A("h")
k = B("k")

f.z = c
n.p = c
m.s = c
m.v = h
m.r = h
i.p = c
c.s = m
c.v = h
c.r = h
e.z = c
d.p = m
b.z = m
h.z = c
k.p = m
assert d.p.s.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: 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.s: C = None
        self.v: A = None
        self.r: A = None
        self.txt = txt

f = A("f")
n = B("n")
m = C("m")
i = B("i")
c = C("c")
e = A("e")
d = B("d")
b = A("b")
h = A("h")
k = B("k")

f.z = c
n.p = c
m.s = c
m.v = h
m.r = h
i.p = c
c.s = m
c.v = h
c.r = h
e.z = c
d.p = m
b.z = m
h.z = c
k.p = m
assert d.p.s.r.z.txt == "c"