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

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

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

n = A("n")
g = B("g")
i = C("i")
l = B("l")

n.w = i
g.s = n
g.u = i
g.y = l
i.o = n
i.w = n
l.s = n
l.u = i
l.y = g
assert l.s.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

n = A("n")
g = B("g")
i = C("i")
l = B("l")

n.w = i
g.s = n
g.u = i
g.y = l
i.o = n
i.w = n
l.s = n
l.u = i
l.y = g
assert l.s.w.w.txt == "n"