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

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

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

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

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

l = A("l")
h = B("h")
d = C("d")
i = D("i")
e = E("e")
a = B("a")
m = C("m")

l.w = d
l.p = i
h.s = m
h.p = a
d.q = m
d.s = i
i.s = d
e.v = a
e.w = a
e.r = i
a.s = d
a.p = h
m.q = d
m.s = i
assert e.r.s.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: D = None
        self.txt = txt

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

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

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

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

l = A("l")
h = B("h")
d = C("d")
i = D("i")
e = E("e")
a = B("a")
m = C("m")

l.w = d
l.p = i
h.s = m
h.p = a
d.q = m
d.s = i
i.s = d
e.v = a
e.w = a
e.r = i
a.s = d
a.p = h
m.q = d
m.s = i
assert e.r.s.q.q.q.q.txt == "d"