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

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

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

i = A("i")
h = B("h")
l = C("l")
g = C("g")
a = A("a")
n = B("n")
k = A("k")
d = A("d")

i.q = h
i.r = h
h.p = k
l.o = k
l.r = a
l.y = g
g.o = k
g.r = a
g.y = l
a.q = h
a.r = h
n.p = d
k.q = n
k.r = h
d.q = h
d.r = h
assert n.p.r.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: B = None
        self.txt = txt

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

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

i = A("i")
h = B("h")
l = C("l")
g = C("g")
a = A("a")
n = B("n")
k = A("k")
d = A("d")

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