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

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

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

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

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

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

j.s = e
j.y = e
c.p = j
e.p = j
assert j.s.p.s.txt == "e"