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

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

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

m = A("m")
h = B("h")
g = C("g")
n = C("n")
l = A("l")
c = A("c")
j = A("j")
f = B("f")
d = C("d")
i = C("i")

m.y = c
h.o = f
g.x = c
g.q = n
n.x = c
n.q = i
l.y = m
c.y = j
j.y = l
f.o = h
d.x = j
d.q = i
i.x = l
i.q = g
assert n.x.y.y.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

m = A("m")
h = B("h")
g = C("g")
n = C("n")
l = A("l")
c = A("c")
j = A("j")
f = B("f")
d = C("d")
i = C("i")

m.y = c
h.o = f
g.x = c
g.q = n
n.x = c
n.q = i
l.y = m
c.y = j
j.y = l
f.o = h
d.x = j
d.q = i
i.x = l
i.q = g
assert n.x.y.y.y.y.y.y.y.y.y.txt == "j"