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

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

g = A("g")
n = B("n")
a = B("a")

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

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

g = A("g")
n = B("n")
a = B("a")

g.o = a
g.u = a
n.o = g
a.o = g
assert n.o.o.o.txt == "g"