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

d = A("d")
h = B("h")
k = C("k")
n = B("n")
a = C("a")
i = A("i")
f = C("f")
j = A("j")

d.q = f
h.s = f
k.t = a
k.p = a
n.s = k
a.t = k
a.p = k
i.q = a
f.t = k
f.p = a
j.q = a
assert k.p.t.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: 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.t: C = None
        self.p: C = None
        self.txt = txt

d = A("d")
h = B("h")
k = C("k")
n = B("n")
a = C("a")
i = A("i")
f = C("f")
j = A("j")

d.q = f
h.s = f
k.t = a
k.p = a
n.s = k
a.t = k
a.p = k
i.q = a
f.t = k
f.p = a
j.q = a
assert k.p.t.p.p.p.p.p.p.txt == "k"