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

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

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

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

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

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

j.s = i
i.s = n
i.y = h
k.s = g
c.s = e
b.s = n
n.s = i
n.y = b
h.s = e
g.s = e
g.y = k
e.s = n
e.y = h
assert c.s.y.s.s.y.s.s.y.s.txt == "e"