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

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.u: C = None
        self.r: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.s: C = None
        self.q: E = None
        self.p: B = None
        self.t: E = None
        self.txt = txt

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

d = A("d")
k = B("k")
n = C("n")
g = D("g")
h = E("h")

d.t = g
d.o = k
d.x = h
d.r = h
d.q = h
k.v = n
k.u = n
k.r = d
n.u = g
n.q = h
g.z = n
g.s = n
g.q = h
g.t = h
g.p = k
h.w = d
h.o = d
h.q = k
h.r = g
assert k.r.t.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.o: B = None
        self.x: E = None
        self.r: E = None
        self.q: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.u: C = None
        self.r: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.s: C = None
        self.q: E = None
        self.p: B = None
        self.t: E = None
        self.txt = txt

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

d = A("d")
k = B("k")
n = C("n")
g = D("g")
h = E("h")

d.t = g
d.o = k
d.x = h
d.r = h
d.q = h
k.v = n
k.u = n
k.r = d
n.u = g
n.q = h
g.z = n
g.s = n
g.q = h
g.t = h
g.p = k
h.w = d
h.o = d
h.q = k
h.r = g
assert k.r.t.z.q.txt == "h"