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

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

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

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

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

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

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