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

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

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

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

k.s = i
n.s = i
e.p = n
g.p = l
l.s = e
i.p = n
h.p = l
assert i.p.s.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

k.s = i
n.s = i
e.p = n
g.p = l
l.s = e
i.p = n
h.p = l
assert i.p.s.p.s.txt == "i"