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

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

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

class D:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

b.u = d
b.r = k
i.p = n
c.v = d
c.p = f
d.s = b
k.w = f
k.x = c
k.s = i
k.p = n
k.r = d
g.u = d
g.r = n
f.p = n
n.w = f
n.x = c
n.s = i
n.p = k
n.r = d
a.u = d
a.r = k
assert a.r.r.s.u.s.r.p.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.r: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

b.u = d
b.r = k
i.p = n
c.v = d
c.p = f
d.s = b
k.w = f
k.x = c
k.s = i
k.p = n
k.r = d
g.u = d
g.r = n
f.p = n
n.w = f
n.x = c
n.s = i
n.p = k
n.r = d
a.u = d
a.r = k
assert a.r.r.s.u.s.r.p.x.v.txt == "d"