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

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

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

i = A("i")
n = B("n")
m = C("m")
e = C("e")
b = C("b")
a = C("a")
h = C("h")
g = B("g")
k = A("k")

i.z = k
n.o = g
n.y = g
n.p = k
m.y = i
e.y = i
b.y = i
a.y = k
h.y = i
g.o = n
g.y = n
g.p = k
k.z = i
assert e.y.z.z.z.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.o: B = None
        self.y: B = None
        self.p: A = None
        self.txt = txt

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

i = A("i")
n = B("n")
m = C("m")
e = C("e")
b = C("b")
a = C("a")
h = C("h")
g = B("g")
k = A("k")

i.z = k
n.o = g
n.y = g
n.p = k
m.y = i
e.y = i
b.y = i
a.y = k
h.y = i
g.o = n
g.y = n
g.p = k
k.z = i
assert e.y.z.z.z.z.z.z.z.txt == "k"