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

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.s: D = None
        self.y: C = None
        self.v: C = None
        self.x: C = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
f = C("f")
d = D("d")
k = E("k")

h.p = k
h.v = k
g.t = f
g.y = f
g.v = f
g.x = f
g.s = d
f.y = d
f.x = g
d.p = f
d.u = h
d.w = g
d.x = g
k.p = g
k.x = g
assert d.w.x.y.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.v: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.s: D = None
        self.y: C = None
        self.v: C = None
        self.x: C = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
f = C("f")
d = D("d")
k = E("k")

h.p = k
h.v = k
g.t = f
g.y = f
g.v = f
g.x = f
g.s = d
f.y = d
f.x = g
d.p = f
d.u = h
d.w = g
d.x = g
k.p = g
k.x = g
assert d.w.x.y.p.y.txt == "d"