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

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

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

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

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

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

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

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

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

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

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

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

b.u = i
b.w = m
a.p = b
a.o = m
a.r = k
m.o = b
m.t = b
m.x = b
k.t = i
i.u = k
i.z = a
assert m.t.u.u.txt == "k"