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

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.v: D = None
        self.r: E = None
        self.q: A = None
        self.o: D = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.v: D = None
        self.r: E = None
        self.q: A = None
        self.o: D = None
        self.txt = txt

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

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

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

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

a.v = e
a.x = m
a.p = n
m.z = e
m.r = e
m.v = h
m.o = h
m.q = a
n.v = a
n.q = a
n.t = h
h.q = n
e.p = h
e.r = n
assert e.p.q.t.q.txt == "n"