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.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.x: D = None
        self.z: B = None
        self.txt = txt

c = A("c")
l = B("l")
k = C("k")
e = D("e")
f = D("f")

c.z = k
l.z = k
k.t = l
e.p = l
e.z = l
e.x = f
f.p = l
f.z = l
f.x = e
assert c.z.t.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.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.p: B = None
        self.x: D = None
        self.z: B = None
        self.txt = txt

c = A("c")
l = B("l")
k = C("k")
e = D("e")
f = D("f")

c.z = k
l.z = k
k.t = l
e.p = l
e.z = l
e.x = f
f.p = l
f.z = l
f.x = e
assert c.z.t.z.txt == "k"