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

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

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

k = A("k")
f = B("f")
b = C("b")
j = A("j")
h = B("h")
l = C("l")
n = A("n")
g = A("g")
d = A("d")

k.p = f
f.p = h
b.y = f
b.o = h
j.p = h
h.p = f
l.y = h
l.o = h
n.p = f
g.p = f
d.p = f
assert k.p.p.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

k = A("k")
f = B("f")
b = C("b")
j = A("j")
h = B("h")
l = C("l")
n = A("n")
g = A("g")
d = A("d")

k.p = f
f.p = h
b.y = f
b.o = h
j.p = h
h.p = f
l.y = h
l.o = h
n.p = f
g.p = f
d.p = f
assert k.p.p.p.p.p.p.p.p.p.txt == "f"