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

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

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

f = A("f")
g = B("g")
a = C("a")
i = C("i")

f.u = i
f.w = i
g.q = f
g.o = f
a.s = i
i.s = a
assert i.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.w: C = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
a = C("a")
i = C("i")

f.u = i
f.w = i
g.q = f
g.o = f
a.s = i
i.s = a
assert i.s.s.s.s.txt == "i"