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

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

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

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

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

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

h.w = j
h.v = b
b.y = c
b.u = h
c.y = b
c.u = j
j.w = h
j.v = c
assert j.v.y.y.txt == "c"