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

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

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

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

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

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

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

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

c.w = g
g.s = c
g.o = i
e.y = i
e.w = i
i.y = e
i.w = e
assert c.w.s.w.txt == "g"