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

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

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

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

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

a.p = c
a.w = d
a.v = i
b.r = d
l.z = i
l.y = c
i.w = a
i.y = a
e.w = a
e.y = h
h.p = c
h.w = d
h.v = e
c.z = e
c.y = d
n.r = l
d.z = i
d.y = l
assert h.w.z.w.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: C = None
        self.v: D = None
        self.txt = txt

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

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

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

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

a.p = c
a.w = d
a.v = i
b.r = d
l.z = i
l.y = c
i.w = a
i.y = a
e.w = a
e.y = h
h.p = c
h.w = d
h.v = e
c.z = e
c.y = d
n.r = l
d.z = i
d.y = l
assert h.w.z.w.v.y.txt == "a"