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

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

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

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

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

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

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

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

n.s = j
f.u = n
f.z = e
k.r = f
k.o = j
d.u = a
d.z = a
j.r = f
j.o = k
a.s = k
e.s = j
assert k.r.z.s.r.u.s.txt == "j"