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

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

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

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

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

m = A("m")
d = B("d")
l = C("l")
g = D("g")
i = E("i")
c = D("c")
b = E("b")
n = C("n")
a = A("a")

m.t = d
d.t = i
d.r = m
l.u = n
g.u = d
g.p = d
g.s = c
i.q = d
i.p = d
i.v = l
i.s = g
i.u = b
c.u = d
c.p = d
c.s = g
b.q = d
b.p = d
b.v = l
b.s = c
b.u = i
n.u = l
a.t = d
assert m.t.r.t.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

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

m = A("m")
d = B("d")
l = C("l")
g = D("g")
i = E("i")
c = D("c")
b = E("b")
n = C("n")
a = A("a")

m.t = d
d.t = i
d.r = m
l.u = n
g.u = d
g.p = d
g.s = c
i.q = d
i.p = d
i.v = l
i.s = g
i.u = b
c.u = d
c.p = d
c.s = g
b.q = d
b.p = d
b.v = l
b.s = c
b.u = i
n.u = l
a.t = d
assert m.t.r.t.t.s.txt == "g"