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

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

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

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

e.z = a
e.s = f
m.r = k
j.p = k
f.p = b
b.z = j
b.s = f
k.z = f
k.s = j
d.z = a
d.s = j
n.r = e
a.p = k
assert d.z.p.z.p.z.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.s: C = None
        self.txt = txt

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

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

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

e.z = a
e.s = f
m.r = k
j.p = k
f.p = b
b.z = j
b.s = f
k.z = f
k.s = j
d.z = a
d.s = j
n.r = e
a.p = k
assert d.z.p.z.p.z.p.s.txt == "j"