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

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: C = None
        self.u: A = None
        self.t: A = None
        self.w: A = None
        self.txt = txt

h = A("h")
n = B("n")
d = C("d")
b = D("b")
l = E("l")

h.y = l
n.u = d
n.s = b
n.r = h
d.w = b
b.z = d
b.w = h
l.q = n
l.o = d
l.u = h
l.t = h
l.w = h
assert d.w.z.w.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: C = None
        self.u: A = None
        self.t: A = None
        self.w: A = None
        self.txt = txt

h = A("h")
n = B("n")
d = C("d")
b = D("b")
l = E("l")

h.y = l
n.u = d
n.s = b
n.r = h
d.w = b
b.z = d
b.w = h
l.q = n
l.o = d
l.u = h
l.t = h
l.w = h
assert d.w.z.w.z.w.txt == "b"