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

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

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

c = A("c")
f = B("f")
e = C("e")
n = B("n")
m = C("m")
k = C("k")

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

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

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

c = A("c")
f = B("f")
e = C("e")
n = B("n")
m = C("m")
k = C("k")

c.o = k
f.r = n
f.z = n
e.s = n
n.r = f
n.z = f
m.s = f
k.s = n
assert k.s.r.z.z.r.txt == "n"