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

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

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

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

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

m = A("m")
k = B("k")
b = C("b")
a = D("a")
i = E("i")

m.v = k
m.p = a
k.r = a
k.z = a
k.q = i
b.w = k
b.t = a
b.s = m
a.z = b
a.t = k
i.u = k
assert a.z.t.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.p: D = None
        self.txt = txt

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

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

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

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

m = A("m")
k = B("k")
b = C("b")
a = D("a")
i = E("i")

m.v = k
m.p = a
k.r = a
k.z = a
k.q = i
b.w = k
b.t = a
b.s = m
a.z = b
a.t = k
i.u = k
assert a.z.t.z.t.txt == "a"