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

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

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

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

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

e = A("e")
i = B("i")
n = C("n")
m = D("m")
k = E("k")
a = C("a")

e.y = k
e.x = k
i.o = n
i.p = e
i.r = a
n.u = m
m.w = k
k.z = m
k.r = m
a.u = m
assert m.w.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.x: E = None
        self.txt = txt

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

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

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

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

e = A("e")
i = B("i")
n = C("n")
m = D("m")
k = E("k")
a = C("a")

e.y = k
e.x = k
i.o = n
i.p = e
i.r = a
n.u = m
m.w = k
k.z = m
k.r = m
a.u = m
assert m.w.r.w.txt == "k"