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

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

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

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

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

i = A("i")
d = B("d")
m = C("m")
n = D("n")
h = E("h")
g = C("g")
a = B("a")
e = C("e")

i.x = h
d.t = e
d.z = a
d.v = g
m.v = a
n.p = h
n.v = e
h.r = g
h.v = e
g.v = a
a.t = g
a.v = g
a.z = d
e.v = a
assert e.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

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

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

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

i = A("i")
d = B("d")
m = C("m")
n = D("n")
h = E("h")
g = C("g")
a = B("a")
e = C("e")

i.x = h
d.t = e
d.z = a
d.v = g
m.v = a
n.p = h
n.v = e
h.r = g
h.v = e
g.v = a
a.t = g
a.v = g
a.z = d
e.v = a
assert e.v.v.v.v.v.txt == "a"