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

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

m = A("m")
k = B("k")
b = A("b")
g = B("g")

m.o = b
m.s = b
k.v = g
b.o = m
b.s = m
g.v = k
assert g.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.s: A = None
        self.txt = txt

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

m = A("m")
k = B("k")
b = A("b")
g = B("g")

m.o = b
m.s = b
k.v = g
b.o = m
b.s = m
g.v = k
assert g.v.v.v.v.txt == "g"