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

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

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

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

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

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

b.v = j
b.y = m
j.w = b
c.v = j
c.y = b
m.v = j
m.y = b
assert j.w.v.w.y.txt == "m"