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

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

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

n = A("n")
a = B("a")
i = C("i")
d = C("d")
k = C("k")
c = B("c")

n.p = c
n.y = c
a.p = i
a.y = c
i.v = a
d.v = c
k.v = a
c.p = i
c.y = a
assert k.v.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: B = None
        self.txt = txt

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

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

n = A("n")
a = B("a")
i = C("i")
d = C("d")
k = C("k")
c = B("c")

n.p = c
n.y = c
a.p = i
a.y = c
i.v = a
d.v = c
k.v = a
c.p = i
c.y = a
assert k.v.y.y.y.y.txt == "a"