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

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

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

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

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

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

e.y = k
e.x = k
j.s = d
d.s = j
k.y = e
k.x = e
assert e.x.x.y.txt == "k"