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

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

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

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

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

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

a.v = b
a.w = c
e.w = d
e.s = d
c.w = d
c.s = b
h.v = b
h.w = e
b.v = a
b.w = n
d.v = b
d.w = i
n.w = a
n.s = d
i.w = d
i.s = d
j.w = b
j.s = b
assert e.s.w.w.w.w.v.w.s.w.txt == "i"