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

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

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

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

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

e = A("e")
d = B("d")
a = C("a")
h = D("h")
k = E("k")

e.y = k
e.v = h
e.x = a
d.x = a
a.q = h
a.r = k
h.x = e
h.s = a
k.v = e
k.r = h
k.y = d
assert e.v.s.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.v: D = None
        self.x: C = None
        self.txt = txt

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

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

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

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

e = A("e")
d = B("d")
a = C("a")
h = D("h")
k = E("k")

e.y = k
e.v = h
e.x = a
d.x = a
a.q = h
a.r = k
h.x = e
h.s = a
k.v = e
k.r = h
k.y = d
assert e.v.s.q.x.txt == "e"