class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.p: B = None
        self.o: E = None
        self.z: A = None
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

h = A("h")
n = B("n")
k = C("k")
c = D("c")
m = E("m")
e = A("e")

h.t = e
h.z = e
h.p = n
h.q = n
h.o = m
n.w = k
n.q = c
n.r = c
k.p = m
c.p = n
m.p = h
e.t = h
e.z = h
e.p = n
e.q = n
e.o = m
assert h.q.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.p: B = None
        self.o: E = None
        self.z: A = None
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

h = A("h")
n = B("n")
k = C("k")
c = D("c")
m = E("m")
e = A("e")

h.t = e
h.z = e
h.p = n
h.q = n
h.o = m
n.w = k
n.q = c
n.r = c
k.p = m
c.p = n
m.p = h
e.t = h
e.z = h
e.p = n
e.q = n
e.o = m
assert h.q.w.p.txt == "m"