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

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

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

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

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

h = A("h")
f = B("f")
a = C("a")
e = D("e")
l = E("l")

h.r = l
f.y = h
f.x = l
f.z = a
f.u = a
f.o = e
a.p = e
a.s = e
a.r = e
a.v = f
e.s = h
e.t = h
e.z = l
l.r = f
l.w = h
l.z = a
assert h.r.z.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

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

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

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

h = A("h")
f = B("f")
a = C("a")
e = D("e")
l = E("l")

h.r = l
f.y = h
f.x = l
f.z = a
f.u = a
f.o = e
a.p = e
a.s = e
a.r = e
a.v = f
e.s = h
e.t = h
e.z = l
l.r = f
l.w = h
l.z = a
assert h.r.z.p.z.txt == "l"