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

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

g = A("g")
a = B("a")
l = B("l")
b = A("b")

g.w = l
g.y = l
a.v = l
l.v = a
b.w = l
b.y = a
assert a.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: B = None
        self.txt = txt

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

g = A("g")
a = B("a")
l = B("l")
b = A("b")

g.w = l
g.y = l
a.v = l
l.v = a
b.w = l
b.y = a
assert a.v.v.v.v.txt == "a"