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

class B:
    def __init__(self, txt: str):
        self.x: E = None
        self.s: D = None
        self.r: A = None
        self.z: C = None
        self.txt = txt

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

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

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

k = A("k")
l = B("l")
d = C("d")
g = D("g")
j = E("j")
a = E("a")

k.z = j
k.y = d
l.x = j
l.s = g
l.r = k
l.z = d
d.w = g
d.u = k
g.q = l
j.r = k
a.r = k
assert k.y.u.z.r.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.y: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: E = None
        self.s: D = None
        self.r: A = None
        self.z: C = None
        self.txt = txt

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

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

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

k = A("k")
l = B("l")
d = C("d")
g = D("g")
j = E("j")
a = E("a")

k.z = j
k.y = d
l.x = j
l.s = g
l.r = k
l.z = d
d.w = g
d.u = k
g.q = l
j.r = k
a.r = k
assert k.y.u.z.r.y.w.txt == "g"