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

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

l = A("l")
n = B("n")
b = A("b")
j = B("j")
g = B("g")
k = A("k")
d = B("d")
h = A("h")

l.v = g
l.w = n
n.w = b
b.v = j
b.w = j
j.w = b
g.w = l
k.v = d
k.w = n
d.w = l
h.v = n
h.w = g
assert d.w.v.w.v.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.w: B = None
        self.txt = txt

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

l = A("l")
n = B("n")
b = A("b")
j = B("j")
g = B("g")
k = A("k")
d = B("d")
h = A("h")

l.v = g
l.w = n
n.w = b
b.v = j
b.w = j
j.w = b
g.w = l
k.v = d
k.w = n
d.w = l
h.v = n
h.w = g
assert d.w.v.w.v.w.w.w.txt == "b"