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

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

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

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

c = A("c")
f = B("f")
h = C("h")
l = D("l")

c.z = l
c.p = l
c.w = f
c.t = f
f.y = h
h.o = f
l.r = h
l.z = h
assert f.y.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.w: B = None
        self.p: D = None
        self.t: B = None
        self.txt = txt

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

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

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

c = A("c")
f = B("f")
h = C("h")
l = D("l")

c.z = l
c.p = l
c.w = f
c.t = f
f.y = h
h.o = f
l.r = h
l.z = h
assert f.y.o.y.txt == "h"