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

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

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

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

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

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

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

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

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

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

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

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

k.x = m
i.t = e
i.z = k
e.w = k
e.z = b
e.o = m
b.x = e
m.t = k
m.y = k
m.r = b
assert e.w.x.r.x.o.txt == "m"