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

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

k = A("k")
f = B("f")
j = A("j")
c = B("c")
h = A("h")
d = B("d")
g = A("g")
a = A("a")
m = A("m")
l = A("l")

k.x = c
k.w = d
f.v = j
j.x = c
j.w = d
c.v = j
h.x = f
h.w = d
d.v = l
g.x = c
g.w = c
a.x = c
a.w = d
m.x = f
m.w = f
l.x = c
l.w = c
assert l.x.v.x.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.w: B = None
        self.txt = txt

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

k = A("k")
f = B("f")
j = A("j")
c = B("c")
h = A("h")
d = B("d")
g = A("g")
a = A("a")
m = A("m")
l = A("l")

k.x = c
k.w = d
f.v = j
j.x = c
j.w = d
c.v = j
h.x = f
h.w = d
d.v = l
g.x = c
g.w = c
a.x = c
a.w = d
m.x = f
m.w = f
l.x = c
l.w = c
assert l.x.v.x.v.w.txt == "d"