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

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

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

g.o = b
g.s = b
f.y = b
f.t = b
b.o = g
b.s = g
i.y = b
i.t = g
assert g.o.s.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.s: A = None
        self.txt = txt

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

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

g.o = b
g.s = b
f.y = b
f.t = b
b.o = g
b.s = g
i.y = b
i.t = g
assert g.o.s.o.o.txt == "g"