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

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

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

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

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

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

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