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

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

k = A("k")
l = B("l")
a = A("a")
b = B("b")
c = A("c")
e = B("e")
h = A("h")

k.s = b
l.o = e
l.y = h
a.s = e
b.o = l
b.y = k
c.s = b
e.o = b
e.y = k
h.s = l
assert e.o.y.s.o.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

k = A("k")
l = B("l")
a = A("a")
b = B("b")
c = A("c")
e = B("e")
h = A("h")

k.s = b
l.o = e
l.y = h
a.s = e
b.o = l
b.y = k
c.s = b
e.o = b
e.y = k
h.s = l
assert e.o.y.s.o.o.y.txt == "k"