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

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

j = A("j")
c = B("c")
n = B("n")
i = B("i")
k = A("k")
h = B("h")
e = B("e")
d = B("d")
m = A("m")

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

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

j = A("j")
c = B("c")
n = B("n")
i = B("i")
k = A("k")
h = B("h")
e = B("e")
d = B("d")
m = A("m")

j.s = i
j.y = i
c.v = i
n.v = d
i.v = h
k.s = e
k.y = h
h.v = d
e.v = h
d.v = e
m.s = d
m.y = h
assert k.y.v.v.v.txt == "h"