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

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

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

m = A("m")
n = B("n")
i = C("i")
a = A("a")
h = B("h")
l = C("l")
k = C("k")

m.p = n
n.y = l
n.o = m
n.w = h
i.x = l
i.o = a
i.t = k
a.p = n
h.y = i
h.o = a
h.w = n
l.x = i
l.o = m
l.t = k
k.x = i
k.o = a
k.t = l
assert m.p.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

m = A("m")
n = B("n")
i = C("i")
a = A("a")
h = B("h")
l = C("l")
k = C("k")

m.p = n
n.y = l
n.o = m
n.w = h
i.x = l
i.o = a
i.t = k
a.p = n
h.y = i
h.o = a
h.w = n
l.x = i
l.o = m
l.t = k
k.x = i
k.o = a
k.t = l
assert m.p.w.w.txt == "n"