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

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

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

c.t = g
i.z = g
i.o = c
b.z = g
b.o = c
g.z = i
g.o = c
assert g.z.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

c.t = g
i.z = g
i.o = c
b.z = g
b.o = c
g.z = i
g.o = c
assert g.z.o.t.txt == "g"