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

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.t: E = None
        self.z: D = None
        self.q: A = None
        self.s: E = 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.w: A = None
        self.x: B = None
        self.y: B = None
        self.txt = txt

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

k = A("k")
d = B("d")
b = C("b")
c = D("c")
e = E("e")

k.r = b
k.x = b
k.u = b
d.w = k
d.q = k
d.t = e
d.s = e
d.z = c
b.x = c
c.w = k
c.x = d
c.y = d
e.t = d
e.z = c
e.w = b
assert k.r.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: C = None
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.t: E = None
        self.z: D = None
        self.q: A = None
        self.s: E = 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.w: A = None
        self.x: B = None
        self.y: B = None
        self.txt = txt

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

k = A("k")
d = B("d")
b = C("b")
c = D("c")
e = E("e")

k.r = b
k.x = b
k.u = b
d.w = k
d.q = k
d.t = e
d.s = e
d.z = c
b.x = c
c.w = k
c.x = d
c.y = d
e.t = d
e.z = c
e.w = b
assert k.r.x.y.txt == "d"