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

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

g = A("g")
n = B("n")
h = B("h")
c = A("c")
k = A("k")
b = A("b")
e = A("e")
m = A("m")
i = B("i")
f = B("f")

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

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

g = A("g")
n = B("n")
h = B("h")
c = A("c")
k = A("k")
b = A("b")
e = A("e")
m = A("m")
i = B("i")
f = B("f")

g.v = i
n.w = f
h.w = i
c.v = i
k.v = n
b.v = i
e.v = n
m.v = n
i.w = h
f.w = i
assert e.v.w.w.w.w.w.txt == "h"