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

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

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

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

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

e = A("e")
g = B("g")
d = C("d")
c = D("c")
k = E("k")
i = B("i")
n = A("n")
a = E("a")

e.r = c
e.p = n
e.w = n
g.r = d
g.z = i
g.u = a
d.x = i
d.t = i
d.p = k
c.t = d
c.y = n
c.r = i
c.x = k
k.v = d
k.q = c
i.r = d
i.z = g
i.u = a
n.r = c
n.p = e
n.w = e
a.v = d
a.q = c
assert k.v.p.q.r.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.p: A = None
        self.w: A = None
        self.txt = txt

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

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

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

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

e = A("e")
g = B("g")
d = C("d")
c = D("c")
k = E("k")
i = B("i")
n = A("n")
a = E("a")

e.r = c
e.p = n
e.w = n
g.r = d
g.z = i
g.u = a
d.x = i
d.t = i
d.p = k
c.t = d
c.y = n
c.r = i
c.x = k
k.v = d
k.q = c
i.r = d
i.z = g
i.u = a
n.r = c
n.p = e
n.w = e
a.v = d
a.q = c
assert k.v.p.q.r.u.v.txt == "d"