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

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

n = A("n")
b = B("b")
d = A("d")
k = A("k")
i = B("i")
h = B("h")
f = A("f")
e = B("e")
j = B("j")
g = A("g")

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

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

n = A("n")
b = B("b")
d = A("d")
k = A("k")
i = B("i")
h = B("h")
f = A("f")
e = B("e")
j = B("j")
g = A("g")

n.u = b
b.v = i
b.w = h
d.u = h
k.u = i
i.v = j
i.w = b
h.v = j
h.w = e
f.u = i
e.v = h
e.w = i
j.v = b
j.w = e
g.u = h
assert k.u.w.v.w.w.v.v.txt == "b"