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

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

f = A("f")
d = B("d")
e = B("e")
g = A("g")
i = B("i")
l = B("l")
m = B("m")
n = A("n")
a = A("a")
b = B("b")

f.w = l
f.v = l
d.u = l
e.u = i
g.w = m
g.v = b
i.u = l
l.u = m
m.u = e
n.w = d
n.v = e
a.w = i
a.v = d
b.u = i
assert m.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.v: B = None
        self.txt = txt

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

f = A("f")
d = B("d")
e = B("e")
g = A("g")
i = B("i")
l = B("l")
m = B("m")
n = A("n")
a = A("a")
b = B("b")

f.w = l
f.v = l
d.u = l
e.u = i
g.w = m
g.v = b
i.u = l
l.u = m
m.u = e
n.w = d
n.v = e
a.w = i
a.v = d
b.u = i
assert m.u.u.u.u.u.txt == "e"