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

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

l = A("l")
k = B("k")
e = B("e")
i = A("i")
h = A("h")
j = B("j")

l.s = h
l.o = h
k.p = i
k.w = l
e.p = l
e.w = i
i.s = h
i.o = h
h.s = l
h.o = l
j.p = h
j.w = l
assert i.o.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.o: A = None
        self.txt = txt

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

l = A("l")
k = B("k")
e = B("e")
i = A("i")
h = A("h")
j = B("j")

l.s = h
l.o = h
k.p = i
k.w = l
e.p = l
e.w = i
i.s = h
i.o = h
h.s = l
h.o = l
j.p = h
j.w = l
assert i.o.s.s.txt == "h"