class A:
    def __init__(self, txt: str):
        self.y: B = 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.p: B = None
        self.txt = txt

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

j.y = g
g.u = l
i.p = a
k.p = a
l.y = a
a.u = j
n.y = a
e.y = a
h.y = g
m.y = g
assert j.y.u.y.u.y.u.y.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = 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.p: B = None
        self.txt = txt

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

j.y = g
g.u = l
i.p = a
k.p = a
l.y = a
a.u = j
n.y = a
e.y = a
h.y = g
m.y = g
assert j.y.u.y.u.y.u.y.u.y.txt == "g"