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

n = A("n")
a = B("a")
j = C("j")
i = A("i")
l = B("l")
k = B("k")
c = B("c")
g = C("g")
f = A("f")
d = C("d")

n.p = f
n.r = f
n.q = c
a.y = n
j.o = a
i.p = n
i.r = f
i.q = c
l.y = i
k.y = f
c.y = f
g.o = a
f.p = i
f.r = i
f.q = c
d.o = a
assert d.o.y.q.y.q.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.r: A = None
        self.q: B = 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.o: B = None
        self.txt = txt

n = A("n")
a = B("a")
j = C("j")
i = A("i")
l = B("l")
k = B("k")
c = B("c")
g = C("g")
f = A("f")
d = C("d")

n.p = f
n.r = f
n.q = c
a.y = n
j.o = a
i.p = n
i.r = f
i.q = c
l.y = i
k.y = f
c.y = f
g.o = a
f.p = i
f.r = i
f.q = c
d.o = a
assert d.o.y.q.y.q.y.r.txt == "i"