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

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

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

n = A("n")
b = B("b")
h = C("h")
a = C("a")
i = A("i")
l = B("l")
m = A("m")
k = C("k")
d = C("d")

n.w = i
n.o = m
b.r = i
b.v = k
b.q = k
h.w = i
a.w = i
i.w = n
i.o = n
l.r = i
l.v = d
l.q = k
m.w = n
m.o = n
k.w = i
d.w = m
assert b.r.o.o.o.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.o: A = None
        self.txt = txt

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

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

n = A("n")
b = B("b")
h = C("h")
a = C("a")
i = A("i")
l = B("l")
m = A("m")
k = C("k")
d = C("d")

n.w = i
n.o = m
b.r = i
b.v = k
b.q = k
h.w = i
a.w = i
i.w = n
i.o = n
l.r = i
l.v = d
l.q = k
m.w = n
m.o = n
k.w = i
d.w = m
assert b.r.o.o.o.o.w.txt == "n"