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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

n = A("n")
h = B("h")
c = C("c")
b = D("b")
i = E("i")
j = D("j")
d = A("d")

n.z = i
h.v = c
c.z = j
c.v = i
b.p = i
b.w = c
i.v = c
j.p = i
j.w = c
d.z = i
assert j.w.v.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

n = A("n")
h = B("h")
c = C("c")
b = D("b")
i = E("i")
j = D("j")
d = A("d")

n.z = i
h.v = c
c.z = j
c.v = i
b.p = i
b.w = c
i.v = c
j.p = i
j.w = c
d.z = i
assert j.w.v.v.z.txt == "j"