class A:
    def __init__(self, txt: str):
        self.z: C = 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.t: D = None
        self.p: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: C = None
        self.v: C = None
        self.txt = txt

b = A("b")
i = B("i")
l = C("l")
f = D("f")

b.z = l
i.w = b
l.t = f
l.p = b
f.y = i
f.s = l
f.v = l
assert l.t.y.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = 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.t: D = None
        self.p: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: C = None
        self.v: C = None
        self.txt = txt

b = A("b")
i = B("i")
l = C("l")
f = D("f")

b.z = l
i.w = b
l.t = f
l.p = b
f.y = i
f.s = l
f.v = l
assert l.t.y.w.z.txt == "l"