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

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

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

k = A("k")
d = B("d")
b = C("b")
h = A("h")

k.w = h
k.x = h
k.z = h
d.w = k
b.u = k
b.q = d
b.o = d
h.w = k
h.x = k
h.z = k
assert h.z.z.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: A = None
        self.z: A = None
        self.txt = txt

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

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

k = A("k")
d = B("d")
b = C("b")
h = A("h")

k.w = h
k.x = h
k.z = h
d.w = k
b.u = k
b.q = d
b.o = d
h.w = k
h.x = k
h.z = k
assert h.z.z.w.w.txt == "h"