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

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

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

e.y = k
j.o = k
j.x = e
k.o = j
k.x = e
assert e.y.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

e.y = k
j.o = k
j.x = e
k.o = j
k.x = e
assert e.y.o.o.txt == "k"