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

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

f = A("f")
d = B("d")
e = A("e")
i = B("i")

f.x = e
d.v = e
e.x = f
i.v = f
assert e.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

f = A("f")
d = B("d")
e = A("e")
i = B("i")

f.x = e
d.v = e
e.x = f
i.v = f
assert e.x.x.x.x.txt == "e"