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

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

n = A("n")
e = B("e")
b = A("b")
d = B("d")
a = B("a")
m = B("m")
k = A("k")
i = B("i")

n.y = e
n.p = k
e.t = k
e.s = k
b.y = e
b.p = n
d.t = n
d.s = k
a.t = b
a.s = b
m.t = n
m.s = k
k.y = i
k.p = b
i.t = k
i.s = n
assert d.s.y.t.p.p.p.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.p: A = None
        self.txt = txt

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

n = A("n")
e = B("e")
b = A("b")
d = B("d")
a = B("a")
m = B("m")
k = A("k")
i = B("i")

n.y = e
n.p = k
e.t = k
e.s = k
b.y = e
b.p = n
d.t = n
d.s = k
a.t = b
a.s = b
m.t = n
m.s = k
k.y = i
k.p = b
i.t = k
i.s = n
assert d.s.y.t.p.p.p.p.y.txt == "e"