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

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

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

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

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

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

n.w = j
n.v = a
i.w = j
j.w = c
j.v = n
l.w = j
a.w = j
a.v = j
h.w = e
e.w = a
e.v = j
c.w = e
c.v = j
assert l.w.w.v.w.txt == "c"