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

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

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

j.w = g
j.y = f
g.s = j
g.r = f
f.s = j
f.r = g
assert j.w.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: B = None
        self.txt = txt

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

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

j.w = g
j.y = f
g.s = j
g.r = f
f.s = j
f.r = g
assert j.w.s.y.txt == "f"