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

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

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

m = A("m")
i = B("i")
e = C("e")
j = C("j")
h = A("h")
a = B("a")
n = A("n")

m.z = i
m.w = n
i.u = h
e.t = a
e.p = i
j.t = i
j.p = a
h.z = a
h.w = n
a.u = m
n.z = i
n.w = m
assert a.u.w.z.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: A = None
        self.txt = txt

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

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

m = A("m")
i = B("i")
e = C("e")
j = C("j")
h = A("h")
a = B("a")
n = A("n")

m.z = i
m.w = n
i.u = h
e.t = a
e.p = i
j.t = i
j.p = a
h.z = a
h.w = n
a.u = m
n.z = i
n.w = m
assert a.u.w.z.u.w.txt == "n"