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

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

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

e = A("e")
f = B("f")
m = C("m")
n = A("n")
i = C("i")

e.o = n
f.s = e
f.w = m
m.y = i
n.o = e
i.y = m
assert f.s.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

e = A("e")
f = B("f")
m = C("m")
n = A("n")
i = C("i")

e.o = n
f.s = e
f.w = m
m.y = i
n.o = e
i.y = m
assert f.s.o.o.txt == "e"