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

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: D = None
        self.s: A = None
        self.v: D = None
        self.t: E = None
        self.txt = txt

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

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

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

d.o = g
a.y = h
n.r = d
n.y = h
n.v = h
n.s = m
n.t = g
h.q = d
h.p = a
h.u = m
h.x = n
h.r = n
g.t = n
m.o = g
assert g.t.r.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: D = None
        self.s: A = None
        self.v: D = None
        self.t: E = None
        self.txt = txt

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

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

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

d.o = g
a.y = h
n.r = d
n.y = h
n.v = h
n.s = m
n.t = g
h.q = d
h.p = a
h.u = m
h.x = n
h.r = n
g.t = n
m.o = g
assert g.t.r.o.t.txt == "n"