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

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

n = A("n")
c = B("c")
b = A("b")
m = A("m")
h = A("h")
f = B("f")
d = B("d")
j = B("j")
k = B("k")
i = A("i")

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

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

n = A("n")
c = B("c")
b = A("b")
m = A("m")
h = A("h")
f = B("f")
d = B("d")
j = B("j")
k = B("k")
i = A("i")

n.w = k
c.v = j
b.w = k
m.w = f
h.w = c
f.v = c
d.v = j
j.v = c
k.v = f
i.w = j
assert f.v.v.v.v.v.v.txt == "j"