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

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

m = A("m")
b = B("b")
j = A("j")
a = A("a")
k = A("k")
i = A("i")
f = A("f")
l = B("l")
n = A("n")

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

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

m = A("m")
b = B("b")
j = A("j")
a = A("a")
k = A("k")
i = A("i")
f = A("f")
l = B("l")
n = A("n")

m.w = a
b.u = l
b.v = f
j.w = n
a.w = m
k.w = f
i.w = n
f.w = j
l.u = b
l.v = m
n.w = a
assert n.w.w.w.w.w.w.txt == "m"