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

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

m = A("m")
k = B("k")
a = A("a")
g = B("g")
h = B("h")
b = A("b")
j = A("j")
i = A("i")

m.x = a
m.o = k
k.s = h
k.v = g
a.x = b
a.o = k
g.s = k
g.v = k
h.s = g
h.v = k
b.x = a
b.o = k
j.x = i
j.o = h
i.x = a
i.o = h
assert k.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: B = None
        self.txt = txt

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

m = A("m")
k = B("k")
a = A("a")
g = B("g")
h = B("h")
b = A("b")
j = A("j")
i = A("i")

m.x = a
m.o = k
k.s = h
k.v = g
a.x = b
a.o = k
g.s = k
g.v = k
h.s = g
h.v = k
b.x = a
b.o = k
j.x = i
j.o = h
i.x = a
i.o = h
assert k.s.s.s.s.txt == "h"