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

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

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

g.v = a
c.o = a
c.s = l
b.o = a
b.s = l
a.v = g
l.o = g
l.s = b
i.o = g
i.s = c
assert c.s.o.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

g.v = a
c.o = a
c.s = l
b.o = a
b.s = l
a.v = g
l.o = g
l.s = b
i.o = g
i.s = c
assert c.s.o.v.v.v.txt == "a"