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

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

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

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

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

i = A("i")
f = B("f")
g = C("g")
h = D("h")
a = E("a")

i.t = h
i.s = h
i.r = h
i.p = g
f.u = g
f.z = i
f.w = h
g.y = f
g.r = f
g.u = h
g.p = h
h.r = g
h.x = f
h.p = a
a.s = i
a.v = g
a.p = h
assert h.x.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.p: C = None
        self.s: D = None
        self.r: D = None
        self.txt = txt

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

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

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

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

i = A("i")
f = B("f")
g = C("g")
h = D("h")
a = E("a")

i.t = h
i.s = h
i.r = h
i.p = g
f.u = g
f.z = i
f.w = h
g.y = f
g.r = f
g.u = h
g.p = h
h.r = g
h.x = f
h.p = a
a.s = i
a.v = g
a.p = h
assert h.x.u.p.txt == "h"