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

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

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

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

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

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

i.s = g
i.o = g
f.u = g
g.s = i
g.o = i
assert i.o.s.s.txt == "g"