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

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

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

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

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

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

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

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

m.z = j
e.t = h
e.w = f
e.z = b
h.y = a
h.u = e
f.z = i
i.z = f
b.t = h
b.w = f
b.z = e
a.y = h
a.u = b
j.z = m
assert m.z.z.z.z.txt == "m"