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

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

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

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

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

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

g.u = i
i.x = g
i.o = c
c.x = g
c.o = i
assert g.u.x.u.txt == "i"