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

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

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

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

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

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

e.r = c
c.x = k
c.y = e
k.x = c
k.y = e
assert e.r.x.y.txt == "e"