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

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

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

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

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

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

h.u = n
h.q = k
h.w = k
h.o = a
h.z = m
a.y = h
a.w = n
k.u = i
k.t = i
k.x = n
n.t = m
i.y = k
i.z = m
i.w = a
i.r = n
m.u = n
m.q = k
m.w = k
m.o = a
m.z = h
assert n.t.o.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.q: C = None
        self.o: B = None
        self.w: C = None
        self.z: A = None
        self.txt = txt

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

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

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

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

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

h.u = n
h.q = k
h.w = k
h.o = a
h.z = m
a.y = h
a.w = n
k.u = i
k.t = i
k.x = n
n.t = m
i.y = k
i.z = m
i.w = a
i.r = n
m.u = n
m.q = k
m.w = k
m.o = a
m.z = h
assert n.t.o.w.t.txt == "m"