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

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

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

k = A("k")
d = B("d")
a = C("a")
i = C("i")
l = A("l")
c = B("c")
f = A("f")
e = B("e")

k.w = d
d.p = a
a.x = c
a.z = i
a.w = l
i.x = e
i.z = a
i.w = f
l.w = c
c.p = i
f.w = d
e.p = a
assert d.p.z.w.w.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

k = A("k")
d = B("d")
a = C("a")
i = C("i")
l = A("l")
c = B("c")
f = A("f")
e = B("e")

k.w = d
d.p = a
a.x = c
a.z = i
a.w = l
i.x = e
i.z = a
i.w = f
l.w = c
c.p = i
f.w = d
e.p = a
assert d.p.z.w.w.p.z.txt == "i"