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

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

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

e = A("e")
k = B("k")
m = C("m")
i = C("i")

e.p = k
k.t = m
k.o = m
k.r = e
m.w = k
m.s = i
i.w = k
i.s = m
assert m.s.w.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

e = A("e")
k = B("k")
m = C("m")
i = C("i")

e.p = k
k.t = m
k.o = m
k.r = e
m.w = k
m.s = i
i.w = k
i.s = m
assert m.s.w.o.w.txt == "k"