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

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

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

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

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

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

h.o = c
h.p = l
l.w = g
l.v = g
g.w = l
g.v = c
c.w = l
c.v = g
assert l.w.w.w.w.txt == "l"