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

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

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

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

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

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

d.s = b
d.v = n
f.w = n
m.s = b
m.v = n
n.w = k
k.w = n
i.s = b
i.v = f
e.s = b
e.v = f
b.s = d
b.v = f
l.w = n
assert n.w.w.w.w.w.w.txt == "n"