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

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

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

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

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

m = A("m")
g = B("g")
d = C("d")
i = D("i")
k = E("k")
f = D("f")

m.z = i
g.u = k
g.t = i
d.o = m
d.x = m
i.t = k
i.q = d
k.z = g
f.t = k
f.q = d
assert k.z.u.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

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

m = A("m")
g = B("g")
d = C("d")
i = D("i")
k = E("k")
f = D("f")

m.z = i
g.u = k
g.t = i
d.o = m
d.x = m
i.t = k
i.q = d
k.z = g
f.t = k
f.q = d
assert k.z.u.z.u.txt == "k"