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

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

k = A("k")
m = B("m")
i = A("i")
e = B("e")
h = B("h")
c = A("c")
g = A("g")

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

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

k = A("k")
m = B("m")
i = A("i")
e = B("e")
h = B("h")
c = A("c")
g = A("g")

k.v = c
m.s = h
m.o = h
i.v = g
e.s = m
e.o = m
h.s = e
h.o = m
c.v = k
g.v = i
assert e.s.o.o.txt == "m"