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

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

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

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

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

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

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

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

b.o = g
b.x = g
a.t = g
g.t = b
g.q = b
assert a.t.t.x.txt == "g"