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

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: E = None
        self.u: A = None
        self.r: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: D = None
        self.o: B = None
        self.p: C = None
        self.txt = txt

k = A("k")
a = B("a")
c = C("c")
i = D("i")
d = E("d")

k.s = i
k.q = i
a.t = c
a.p = d
a.u = k
a.r = i
c.u = d
c.p = k
i.q = k
i.o = k
d.z = c
d.p = c
d.u = i
d.o = a
assert k.s.o.q.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.q: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: E = None
        self.u: A = None
        self.r: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: D = None
        self.o: B = None
        self.p: C = None
        self.txt = txt

k = A("k")
a = B("a")
c = C("c")
i = D("i")
d = E("d")

k.s = i
k.q = i
a.t = c
a.p = d
a.u = k
a.r = i
c.u = d
c.p = k
i.q = k
i.o = k
d.z = c
d.p = c
d.u = i
d.o = a
assert k.s.o.q.o.q.txt == "i"