class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.s: C = None
        self.q: B = None
        self.u: A = None
        self.txt = txt

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

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

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

d = A("d")
e = B("e")
k = C("k")
l = D("l")
h = C("h")
j = A("j")

d.p = l
d.s = k
d.q = e
d.u = j
e.z = l
k.w = e
l.s = h
h.w = e
j.p = l
j.s = h
j.q = e
j.u = d
assert e.z.s.w.z.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.s: C = None
        self.q: B = None
        self.u: A = None
        self.txt = txt

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

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

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

d = A("d")
e = B("e")
k = C("k")
l = D("l")
h = C("h")
j = A("j")

d.p = l
d.s = k
d.q = e
d.u = j
e.z = l
k.w = e
l.s = h
h.w = e
j.p = l
j.s = h
j.q = e
j.u = d
assert e.z.s.w.z.s.w.txt == "e"