class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: C = None
        self.s: C = None
        self.txt = txt

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

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

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

a.y = m
a.s = m
a.p = l
i.y = a
k.z = l
k.y = a
k.o = m
l.z = k
l.o = k
l.y = a
m.z = l
m.y = a
m.o = k
n.y = a
g.y = a
assert m.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: C = None
        self.s: C = None
        self.txt = txt

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

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

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

a.y = m
a.s = m
a.p = l
i.y = a
k.z = l
k.y = a
k.o = m
l.z = k
l.o = k
l.y = a
m.z = l
m.y = a
m.o = k
n.y = a
g.y = a
assert m.y.y.y.txt == "a"