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

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

l = A("l")
k = B("k")
m = B("m")
g = A("g")
a = B("a")
i = B("i")
n = B("n")
h = B("h")

l.s = k
l.u = g
k.o = m
m.o = h
g.s = i
g.u = l
a.o = h
i.o = h
n.o = i
h.o = n
assert k.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.u: A = None
        self.txt = txt

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

l = A("l")
k = B("k")
m = B("m")
g = A("g")
a = B("a")
i = B("i")
n = B("n")
h = B("h")

l.s = k
l.u = g
k.o = m
m.o = h
g.s = i
g.u = l
a.o = h
i.o = h
n.o = i
h.o = n
assert k.o.o.o.txt == "n"