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

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

g = A("g")
h = B("h")
l = B("l")

g.s = h
h.r = g
h.v = g
l.r = g
l.v = g
assert g.s.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

g = A("g")
h = B("h")
l = B("l")

g.s = h
h.r = g
h.v = g
l.r = g
l.v = g
assert g.s.v.s.txt == "h"