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

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

b = A("b")
m = B("m")
e = A("e")
g = A("g")
k = A("k")
f = B("f")
d = A("d")
n = B("n")

b.v = e
b.z = g
m.w = n
e.v = b
e.z = g
g.v = k
g.z = d
k.v = g
k.z = b
f.w = n
d.v = e
d.z = e
n.w = m
assert n.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: A = None
        self.txt = txt

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

b = A("b")
m = B("m")
e = A("e")
g = A("g")
k = A("k")
f = B("f")
d = A("d")
n = B("n")

b.v = e
b.z = g
m.w = n
e.v = b
e.z = g
g.v = k
g.z = d
k.v = g
k.z = b
f.w = n
d.v = e
d.z = e
n.w = m
assert n.w.w.w.w.w.txt == "m"