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

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

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

c = A("c")
g = B("g")
b = C("b")

c.o = b
c.v = b
c.x = b
g.t = b
g.w = c
b.t = g
b.w = g
b.o = c
assert b.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.v: C = None
        self.x: C = None
        self.txt = txt

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

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

c = A("c")
g = B("g")
b = C("b")

c.o = b
c.v = b
c.x = b
g.t = b
g.w = c
b.t = g
b.w = g
b.o = c
assert b.w.t.w.txt == "g"