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

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

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

g = A("g")
m = B("m")
i = C("i")

g.x = m
g.r = m
m.s = i
m.u = i
m.x = g
i.u = m
i.o = g
assert i.u.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: B = None
        self.txt = txt

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

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

g = A("g")
m = B("m")
i = C("i")

g.x = m
g.r = m
m.s = i
m.u = i
m.x = g
i.u = m
i.o = g
assert i.u.u.o.txt == "g"