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

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

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

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

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

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

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