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

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

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

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

l = A("l")
h = B("h")
k = C("k")
a = D("a")

l.p = a
l.x = a
l.t = h
h.p = k
h.y = l
k.y = l
k.z = l
a.z = l
a.o = l
a.w = h
a.u = k
assert k.y.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.x: D = None
        self.t: B = None
        self.txt = txt

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

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

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

l = A("l")
h = B("h")
k = C("k")
a = D("a")

l.p = a
l.x = a
l.t = h
h.p = k
h.y = l
k.y = l
k.z = l
a.z = l
a.o = l
a.w = h
a.u = k
assert k.y.p.z.txt == "l"