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

class B:
    def __init__(self, txt: str):
        self.w: B = None
        self.r: A = None
        self.txt = txt

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

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

e.p = k
n.w = i
n.r = e
a.o = k
a.t = i
i.w = n
i.r = e
k.o = a
k.t = d
d.w = i
d.r = e
assert n.w.w.r.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: B = None
        self.r: A = None
        self.txt = txt

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

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

e.p = k
n.w = i
n.r = e
a.o = k
a.t = i
i.w = n
i.r = e
k.o = a
k.t = d
d.w = i
d.r = e
assert n.w.w.r.p.t.txt == "d"