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

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

j = A("j")
e = B("e")
c = A("c")
b = B("b")

j.x = e
e.u = b
c.x = e
b.u = e
assert j.x.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

j = A("j")
e = B("e")
c = A("c")
b = B("b")

j.x = e
e.u = b
c.x = e
b.u = e
assert j.x.u.u.txt == "e"