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

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

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

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

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

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

b.s = g
g.o = a
a.o = g
assert b.s.o.o.txt == "g"