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

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

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

k = A("k")
a = B("a")
j = C("j")
h = C("h")
f = A("f")
i = C("i")

k.z = f
k.o = a
k.s = a
a.o = h
j.w = f
h.w = k
f.z = k
f.o = a
f.s = a
i.w = f
assert h.w.z.z.z.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.o: B = None
        self.s: B = None
        self.txt = txt

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

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

k = A("k")
a = B("a")
j = C("j")
h = C("h")
f = A("f")
i = C("i")

k.z = f
k.o = a
k.s = a
a.o = h
j.w = f
h.w = k
f.z = k
f.o = a
f.s = a
i.w = f
assert h.w.z.z.z.z.o.txt == "a"