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

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

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

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

i = A("i")
j = B("j")
e = C("e")
c = D("c")
d = C("d")
h = B("h")
a = D("a")
n = C("n")

i.p = a
i.t = a
j.t = a
e.s = a
e.y = n
e.w = c
c.w = i
c.z = e
d.s = a
d.w = a
d.y = n
h.t = a
a.w = i
a.z = e
n.s = c
n.w = c
n.y = d
assert n.w.z.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.t: D = None
        self.txt = txt

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

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

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

i = A("i")
j = B("j")
e = C("e")
c = D("c")
d = C("d")
h = B("h")
a = D("a")
n = C("n")

i.p = a
i.t = a
j.t = a
e.s = a
e.y = n
e.w = c
c.w = i
c.z = e
d.s = a
d.w = a
d.y = n
h.t = a
a.w = i
a.z = e
n.s = c
n.w = c
n.y = d
assert n.w.z.y.w.txt == "c"