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

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

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

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

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

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

b.x = e
b.q = e
e.u = k
k.x = e
k.q = e
assert k.q.u.x.txt == "e"