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

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

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

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

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

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

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

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

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

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

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

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

h.t = a
b.z = h
b.o = d
d.y = h
d.v = n
d.x = a
d.r = b
n.q = a
n.o = a
a.y = n
a.w = b
a.s = b
a.x = d
a.t = h
assert a.x.y.t.t.txt == "h"