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

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

i = A("i")
b = B("b")
l = B("l")
f = B("f")

i.v = l
b.p = i
b.w = i
l.p = i
l.w = i
f.p = i
f.w = i
assert l.p.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

i = A("i")
b = B("b")
l = B("l")
f = B("f")

i.v = l
b.p = i
b.w = i
l.p = i
l.w = i
f.p = i
f.w = i
assert l.p.v.w.txt == "i"