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

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

j = A("j")
e = B("e")
l = B("l")
b = B("b")
d = A("d")

j.y = d
e.u = b
e.s = j
l.u = b
l.s = j
b.u = e
b.s = d
d.y = j
assert e.s.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

j = A("j")
e = B("e")
l = B("l")
b = B("b")
d = A("d")

j.y = d
e.u = b
e.s = j
l.u = b
l.s = j
b.u = e
b.s = d
d.y = j
assert e.s.y.y.txt == "j"