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

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

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

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

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

h = A("h")
i = B("i")
n = C("n")
c = D("c")
a = E("a")

h.v = i
h.y = c
i.s = h
i.z = h
n.s = i
n.t = h
n.y = c
n.z = c
c.x = h
c.r = h
c.t = i
c.w = n
a.q = h
assert i.s.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: D = None
        self.txt = txt

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

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

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

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

h = A("h")
i = B("i")
n = C("n")
c = D("c")
a = E("a")

h.v = i
h.y = c
i.s = h
i.z = h
n.s = i
n.t = h
n.y = c
n.z = c
c.x = h
c.r = h
c.t = i
c.w = n
a.q = h
assert i.s.v.z.txt == "h"