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.s: B = None
        self.y: C = None
        self.v: A = None
        self.txt = txt

h = A("h")
d = B("d")
k = C("k")
e = B("e")
n = C("n")
b = C("b")

h.p = d
d.p = e
k.s = e
k.y = b
k.v = h
e.p = d
n.s = d
n.y = b
n.v = h
b.s = d
b.y = n
b.v = h
assert k.s.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.s: B = None
        self.y: C = None
        self.v: A = None
        self.txt = txt

h = A("h")
d = B("d")
k = C("k")
e = B("e")
n = C("n")
b = C("b")

h.p = d
d.p = e
k.s = e
k.y = b
k.v = h
e.p = d
n.s = d
n.y = b
n.v = h
b.s = d
b.y = n
b.v = h
assert k.s.p.p.p.p.p.txt == "d"