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

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

i = A("i")
j = B("j")
b = B("b")

i.q = j
i.z = j
j.t = b
j.r = i
b.t = j
b.r = i
assert j.t.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: B = None
        self.txt = txt

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

i = A("i")
j = B("j")
b = B("b")

i.q = j
i.z = j
j.t = b
j.r = i
b.t = j
b.r = i
assert j.t.t.r.txt == "i"