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

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

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

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

e = A("e")
n = B("n")
m = C("m")
d = D("d")
a = B("a")

e.w = m
n.q = a
n.t = a
n.z = m
n.p = e
m.z = d
m.y = a
d.z = n
d.x = m
d.o = e
d.u = e
a.q = n
a.t = n
a.z = m
a.p = e
assert e.w.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

e = A("e")
n = B("n")
m = C("m")
d = D("d")
a = B("a")

e.w = m
n.q = a
n.t = a
n.z = m
n.p = e
m.z = d
m.y = a
d.z = n
d.x = m
d.o = e
d.u = e
a.q = n
a.t = n
a.z = m
a.p = e
assert e.w.z.z.txt == "n"