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

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

i = A("i")
a = B("a")
e = A("e")
c = A("c")
k = B("k")

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

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

i = A("i")
a = B("a")
e = A("e")
c = A("c")
k = B("k")

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