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

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

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

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

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

d.p = e
d.w = l
n.s = j
n.q = d
n.t = e
l.q = i
l.o = i
i.u = e
i.w = k
i.r = d
k.p = e
k.w = l
e.s = j
e.q = k
e.t = n
j.u = e
j.w = d
j.r = d
assert d.p.t.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: C = None
        self.txt = txt

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

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

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

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

d.p = e
d.w = l
n.s = j
n.q = d
n.t = e
l.q = i
l.o = i
i.u = e
i.w = k
i.r = d
k.p = e
k.w = l
e.s = j
e.q = k
e.t = n
j.u = e
j.w = d
j.r = d
assert d.p.t.s.u.txt == "e"