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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

h = A("h")
d = B("d")
e = C("e")
m = D("m")
n = E("n")
j = D("j")
l = C("l")
k = C("k")

h.x = j
h.p = j
h.y = m
d.r = e
e.t = m
m.x = d
m.s = d
n.y = j
j.x = d
j.s = d
l.t = m
k.t = m
assert e.t.s.r.t.x.r.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: D = None
        self.p: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

h = A("h")
d = B("d")
e = C("e")
m = D("m")
n = E("n")
j = D("j")
l = C("l")
k = C("k")

h.x = j
h.p = j
h.y = m
d.r = e
e.t = m
m.x = d
m.s = d
n.y = j
j.x = d
j.s = d
l.t = m
k.t = m
assert e.t.s.r.t.x.r.t.x.txt == "d"