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

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

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

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

e = A("e")
g = B("g")
m = C("m")
k = D("k")
f = D("f")
a = A("a")

e.z = a
e.o = m
g.z = m
m.w = g
k.w = g
k.y = g
k.u = a
k.t = a
f.w = g
f.y = g
f.u = a
f.t = a
a.z = e
a.o = m
assert m.w.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.o: C = None
        self.txt = txt

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

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

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

e = A("e")
g = B("g")
m = C("m")
k = D("k")
f = D("f")
a = A("a")

e.z = a
e.o = m
g.z = m
m.w = g
k.w = g
k.y = g
k.u = a
k.t = a
f.w = g
f.y = g
f.u = a
f.t = a
a.z = e
a.o = m
assert m.w.z.w.txt == "g"