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

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

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

m = A("m")
e = B("e")
g = C("g")
c = B("c")
j = C("j")
i = C("i")
a = A("a")
b = B("b")
n = C("n")
d = A("d")

m.y = a
m.q = e
m.p = g
e.s = j
g.p = e
g.o = c
c.s = i
j.p = b
j.o = e
i.p = e
i.o = e
a.y = d
a.q = c
a.p = j
b.s = n
n.p = b
n.o = c
d.y = m
d.q = b
d.p = n
assert b.s.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: B = None
        self.p: C = None
        self.txt = txt

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

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

m = A("m")
e = B("e")
g = C("g")
c = B("c")
j = C("j")
i = C("i")
a = A("a")
b = B("b")
n = C("n")
d = A("d")

m.y = a
m.q = e
m.p = g
e.s = j
g.p = e
g.o = c
c.s = i
j.p = b
j.o = e
i.p = e
i.o = e
a.y = d
a.q = c
a.p = j
b.s = n
n.p = b
n.o = c
d.y = m
d.q = b
d.p = n
assert b.s.o.s.txt == "i"