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

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

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

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

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

d.u = k
d.w = j
d.p = e
j.r = n
c.z = d
n.w = e
n.o = d
n.t = d
n.p = d
k.r = e
e.w = n
e.o = d
e.t = d
e.p = d
assert j.r.w.w.t.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: B = None
        self.p: D = None
        self.txt = txt

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

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

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

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

d.u = k
d.w = j
d.p = e
j.r = n
c.z = d
n.w = e
n.o = d
n.t = d
n.p = d
k.r = e
e.w = n
e.o = d
e.t = d
e.p = d
assert j.r.w.w.t.p.p.txt == "d"