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

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

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

k = A("k")
i = B("i")
d = C("d")
b = B("b")
f = A("f")
a = C("a")

k.z = a
i.z = a
i.t = a
d.x = b
b.z = a
b.t = a
f.z = d
a.x = i
assert k.z.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

k = A("k")
i = B("i")
d = C("d")
b = B("b")
f = A("f")
a = C("a")

k.z = a
i.z = a
i.t = a
d.x = b
b.z = a
b.t = a
f.z = d
a.x = i
assert k.z.x.z.txt == "a"