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

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

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

g.y = e
e.s = c
c.y = e
assert e.s.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

g.y = e
e.s = c
c.y = e
assert e.s.y.s.txt == "c"