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

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

e = A("e")
n = B("n")
i = B("i")
b = B("b")
j = A("j")
h = A("h")

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

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

e = A("e")
n = B("n")
i = B("i")
b = B("b")
j = A("j")
h = A("h")

e.s = b
e.o = h
n.s = h
i.s = j
b.s = j
j.s = i
j.o = h
h.s = i
h.o = e
assert n.s.o.o.o.txt == "e"