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

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

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

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

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

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

c.v = l
l.v = c
l.w = h
h.v = l
assert c.v.v.v.txt == "l"