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

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

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

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

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

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

e.r = i
e.y = l
l.p = e
l.u = i
i.s = h
h.r = e
h.x = e
h.v = l
h.u = i
f.x = i
f.p = e
f.w = h
assert h.r.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.y: B = None
        self.txt = txt

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

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

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

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

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

e.r = i
e.y = l
l.p = e
l.u = i
i.s = h
h.r = e
h.x = e
h.v = l
h.u = i
f.x = i
f.p = e
f.w = h
assert h.r.r.s.txt == "h"