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

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

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

e = A("e")
g = B("g")
i = C("i")
j = B("j")

e.o = g
g.w = i
i.w = j
i.y = e
j.w = i
assert i.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

e = A("e")
g = B("g")
i = C("i")
j = B("j")

e.o = g
g.w = i
i.w = j
i.y = e
j.w = i
assert i.w.w.w.w.txt == "i"