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

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

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

j.w = f
j.x = f
f.p = j
e.w = f
e.x = f
assert f.p.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: B = None
        self.txt = txt

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

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

j.w = f
j.x = f
f.p = j
e.w = f
e.x = f
assert f.p.x.p.txt == "j"