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

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

j = A("j")
e = B("e")
d = B("d")
g = B("g")
n = A("n")
b = B("b")
l = A("l")
h = A("h")

j.o = d
e.s = n
d.s = h
g.s = j
n.o = b
b.s = h
l.o = d
h.o = d
assert n.o.s.o.s.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

j = A("j")
e = B("e")
d = B("d")
g = B("g")
n = A("n")
b = B("b")
l = A("l")
h = A("h")

j.o = d
e.s = n
d.s = h
g.s = j
n.o = b
b.s = h
l.o = d
h.o = d
assert n.o.s.o.s.o.s.txt == "h"