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

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

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

j.w = c
f.q = c
c.w = j
assert f.q.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

j.w = c
f.q = c
c.w = j
assert f.q.w.w.txt == "c"