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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.z: D = None
        self.t: D = None
        self.w: E = None
        self.txt = txt

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

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

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

j = A("j")
d = B("d")
i = C("i")
h = D("h")
n = E("n")
f = D("f")

j.q = h
d.q = f
d.t = f
d.z = h
d.w = n
i.y = n
i.u = n
h.t = i
h.v = j
h.r = f
n.z = j
n.s = f
n.t = h
f.t = i
f.v = j
f.r = h
assert d.z.r.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.z: D = None
        self.t: D = None
        self.w: E = None
        self.txt = txt

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

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

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

j = A("j")
d = B("d")
i = C("i")
h = D("h")
n = E("n")
f = D("f")

j.q = h
d.q = f
d.t = f
d.z = h
d.w = n
i.y = n
i.u = n
h.t = i
h.v = j
h.r = f
n.z = j
n.s = f
n.t = h
f.t = i
f.v = j
f.r = h
assert d.z.r.v.q.txt == "h"