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

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

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

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

e = A("e")
k = B("k")
d = C("d")
h = D("h")
b = A("b")
a = A("a")
n = B("n")

e.w = n
k.p = d
k.r = n
k.u = b
d.w = n
d.v = a
d.r = h
d.x = k
h.p = d
h.z = d
h.o = n
b.w = n
a.w = k
n.p = d
n.r = k
n.u = a
assert n.u.w.p.v.w.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

e = A("e")
k = B("k")
d = C("d")
h = D("h")
b = A("b")
a = A("a")
n = B("n")

e.w = n
k.p = d
k.r = n
k.u = b
d.w = n
d.v = a
d.r = h
d.x = k
h.p = d
h.z = d
h.o = n
b.w = n
a.w = k
n.p = d
n.r = k
n.u = a
assert n.u.w.p.v.w.r.p.txt == "d"