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.x: B = None
        self.txt = txt

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

k = A("k")
e = B("e")
g = C("g")
i = A("i")
h = B("h")
l = C("l")

k.p = i
e.y = i
e.x = h
g.y = k
g.v = i
i.p = k
h.y = k
h.x = e
l.y = k
l.v = i
assert e.y.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.x: B = None
        self.txt = txt

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

k = A("k")
e = B("e")
g = C("g")
i = A("i")
h = B("h")
l = C("l")

k.p = i
e.y = i
e.x = h
g.y = k
g.v = i
i.p = k
h.y = k
h.x = e
l.y = k
l.v = i
assert e.y.p.p.p.p.txt == "i"