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

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

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

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

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

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

c.q = b
c.z = j
j.y = c
b.q = c
b.z = j
assert j.y.q.z.txt == "j"