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

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

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

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

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

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

e.z = k
k.q = e
m.x = n
n.s = m
n.z = m
n.y = e
n.v = e
b.p = e
b.y = n
h.q = e
d.p = e
d.y = n
assert b.p.z.q.z.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

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

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

e.z = k
k.q = e
m.x = n
n.s = m
n.z = m
n.y = e
n.v = e
b.p = e
b.y = n
h.q = e
d.p = e
d.y = n
assert b.p.z.q.z.q.z.txt == "k"