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

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

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

b = A("b")
f = B("f")
l = C("l")
m = B("m")
i = A("i")
n = A("n")
c = C("c")
a = A("a")
j = C("j")

b.q = c
f.t = b
l.p = c
l.y = c
m.t = b
i.q = c
n.q = l
c.p = l
c.y = j
a.q = l
j.p = c
j.y = l
assert j.y.p.p.y.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

b = A("b")
f = B("f")
l = C("l")
m = B("m")
i = A("i")
n = A("n")
c = C("c")
a = A("a")
j = C("j")

b.q = c
f.t = b
l.p = c
l.y = c
m.t = b
i.q = c
n.q = l
c.p = l
c.y = j
a.q = l
j.p = c
j.y = l
assert j.y.p.p.y.p.y.txt == "c"